mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-23 19:01:23 +01:00
patch(1): don't assume a match if we run out of context to check
Patches with very little context (-U0 and -U1) could get misapplied if the file to be patched changes and a hunk is no longer applicable. Matching with fuzz would be attempted and default to a match when we unexpectedly ran out of context. PR: 74127 Reviewed by: emaste, pfg Approved by: emaste (mentor) Differential Revision: https://reviews.freebsd.org/D12631
This commit is contained in:
parent
8584ed54ab
commit
ed3b305993
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=325365
@ -1026,6 +1026,9 @@ patch_match(LINENUM base, LINENUM offset, LINENUM fuzz)
|
|||||||
const char *plineptr;
|
const char *plineptr;
|
||||||
unsigned short plinelen;
|
unsigned short plinelen;
|
||||||
|
|
||||||
|
/* Patch does not match if we don't have anymore context to use */
|
||||||
|
if (pline > pat_lines)
|
||||||
|
return false;
|
||||||
for (iline = base + offset + fuzz; pline <= pat_lines; pline++, iline++) {
|
for (iline = base + offset + fuzz; pline <= pat_lines; pline++, iline++) {
|
||||||
ilineptr = ifetch(iline, offset >= 0);
|
ilineptr = ifetch(iline, offset >= 0);
|
||||||
if (ilineptr == NULL)
|
if (ilineptr == NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user