mirror of
https://git.proxmox.com/git/libgit2
synced 2026-01-06 22:58:58 +00:00
config: check for EOF before newline
If a line ends at EOF there is no need to check for the newline character and doing so will cause us to read memory beyond the allocatd memory as we check for the Windows-style new-line, which is two bytes long. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
This commit is contained in:
parent
72946881b5
commit
9b7a6a9980
@ -537,12 +537,13 @@ static char *cfg_readline(git_config *cfg)
|
||||
line_src = cfg->reader.read_ptr;
|
||||
line_end = strchr(line_src, '\n');
|
||||
|
||||
while (is_linebreak(line_end))
|
||||
line_end = strchr(line_end + 1, '\n');
|
||||
|
||||
/* no newline at EOF */
|
||||
if (line_end == NULL)
|
||||
line_end = strchr(line_src, 0);
|
||||
else
|
||||
while (is_linebreak(line_end))
|
||||
line_end = strchr(line_end + 1, '\n');
|
||||
|
||||
|
||||
while (line_src < line_end && isspace(*line_src))
|
||||
line_src++;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user