Merge branch 'rs/apply-avoid-over-reading'

Code clean-up to fix possible buffer over-reading.

* rs/apply-avoid-over-reading:
  apply: use starts_with() in gitdiff_verify_name()
This commit is contained in:
Junio C Hamano 2017-07-06 18:14:45 -07:00
commit f9b3252b2a

View File

@ -976,8 +976,7 @@ static int gitdiff_verify_name(struct apply_state *state,
} }
free(another); free(another);
} else { } else {
/* expect "/dev/null" */ if (!starts_with(line, "/dev/null\n"))
if (memcmp("/dev/null", line, 9) || line[9] != '\n')
return error(_("git apply: bad git-diff - expected /dev/null on line %d"), state->linenr); return error(_("git apply: bad git-diff - expected /dev/null on line %d"), state->linenr);
} }