svn commit: r328148 - stable/11/usr.bin/patch
Kyle Evans
kevans at FreeBSD.org
Thu Jan 18 21:53:08 UTC 2018
Author: kevans
Date: Thu Jan 18 21:53:07 2018
New Revision: 328148
URL: https://svnweb.freebsd.org/changeset/base/328148
Log:
MFC r326084: patch(1): don't assume 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.
This also affected patches with higher levels of context but had limited
actual context due to the hunk being located near the beginning/end of file.
PR: 74127
Modified:
stable/11/usr.bin/patch/patch.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/usr.bin/patch/patch.c
==============================================================================
--- stable/11/usr.bin/patch/patch.c Thu Jan 18 21:46:42 2018 (r328147)
+++ stable/11/usr.bin/patch/patch.c Thu Jan 18 21:53:07 2018 (r328148)
@@ -1026,6 +1026,9 @@ patch_match(LINENUM base, LINENUM offset, LINENUM fuzz
const char *plineptr;
unsigned short plinelen;
+ /* Patch does not match if we don't have any more context to use */
+ if (pline > pat_lines)
+ return false;
for (iline = base + offset + fuzz; pline <= pat_lines; pline++, iline++) {
ilineptr = ifetch(iline, offset >= 0);
if (ilineptr == NULL)
More information about the svn-src-stable
mailing list