mirror of
https://github.com/git/git
synced 2024-10-30 04:01:21 +00:00
apply: avoid possible bogus pointer
When parsing "index" lines from a git-diff, we look for a space followed by the mode. If we don't have a space, then we set our pointer to the end-of-line. However, we don't double-check that our end-of-line pointer is valid (e.g., if we got a truncated diff input), which could lead to some wrap-around pointer arithmetic. In most cases this would probably get caught by our "40 < len" check later in the function, but to be on the safe side, let's just use strchrnul to treat end-of-string the same as end-of-line. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
649409b7bc
commit
31bb6d37f9
1 changed files with 1 additions and 1 deletions
|
@ -1073,7 +1073,7 @@ static int gitdiff_index(const char *line, struct patch *patch)
|
|||
|
||||
line = ptr + 2;
|
||||
ptr = strchr(line, ' ');
|
||||
eol = strchr(line, '\n');
|
||||
eol = strchrnul(line, '\n');
|
||||
|
||||
if (!ptr || eol < ptr)
|
||||
ptr = eol;
|
||||
|
|
Loading…
Reference in a new issue