mirror of
https://https.git.savannah.gnu.org/git/patch.git
synced 2026-01-27 09:54:55 +00:00
Fix out-of-bounds access to lines in a patch
This bug can trigger with malformed patches. * src/pch.c (pch_write_line): Avoid out-of-bounds access to p_line[line][p_len[line] - 1] when p_len[line] is 0.
This commit is contained in:
parent
4c43a0b1cb
commit
a0d7fe4589
@ -2276,7 +2276,7 @@ pfetch (lin line)
|
||||
bool
|
||||
pch_write_line (lin line, FILE *file)
|
||||
{
|
||||
bool after_newline = p_line[line][p_len[line] - 1] == '\n';
|
||||
bool after_newline = (p_len[line] > 0) && (p_line[line][p_len[line] - 1] == '\n');
|
||||
if (! fwrite (p_line[line], sizeof (*p_line[line]), p_len[line], file))
|
||||
write_fatal ();
|
||||
return after_newline;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user