Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Nov 2017 17:04:31 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r325365 - head/usr.bin/patch
Message-ID:  <201711031704.vA3H4VIj052389@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Fri Nov  3 17:04:30 2017
New Revision: 325365
URL: https://svnweb.freebsd.org/changeset/base/325365

Log:
  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

Modified:
  head/usr.bin/patch/patch.c

Modified: head/usr.bin/patch/patch.c
==============================================================================
--- head/usr.bin/patch/patch.c	Fri Nov  3 15:57:27 2017	(r325364)
+++ head/usr.bin/patch/patch.c	Fri Nov  3 17:04:30 2017	(r325365)
@@ -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 anymore 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?201711031704.vA3H4VIj052389>