Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Jan 2018 21:53:07 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r328148 - stable/11/usr.bin/patch
Message-ID:  <201801182153.w0ILr7pT019142@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801182153.w0ILr7pT019142>