From owner-svn-src-all@freebsd.org Thu Jan 18 21:53:08 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9E7FEEC5A12; Thu, 18 Jan 2018 21:53:08 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7114C83CAA; Thu, 18 Jan 2018 21:53:08 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9C7D8245A3; Thu, 18 Jan 2018 21:53:07 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0ILr7L9019143; Thu, 18 Jan 2018 21:53:07 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0ILr7pT019142; Thu, 18 Jan 2018 21:53:07 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201801182153.w0ILr7pT019142@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 18 Jan 2018 21:53:07 +0000 (UTC) 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 X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/usr.bin/patch X-SVN-Commit-Revision: 328148 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jan 2018 21:53:08 -0000 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)