From owner-freebsd-bugs@FreeBSD.ORG Fri Nov 19 19:40:33 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9F0C916A4CE for ; Fri, 19 Nov 2004 19:40:33 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1957343D1D for ; Fri, 19 Nov 2004 19:40:33 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id iAJJeWII023781 for ; Fri, 19 Nov 2004 19:40:32 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id iAJJeW7m023779; Fri, 19 Nov 2004 19:40:32 GMT (envelope-from gnats) Resent-Date: Fri, 19 Nov 2004 19:40:32 GMT Resent-Message-Id: <200411191940.iAJJeW7m023779@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Cc: lwall@netlabs.com Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Mikhail Teterin Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 123BE16A4CE for ; Fri, 19 Nov 2004 19:35:14 +0000 (GMT) Received: from out007.verizon.net (out007pub.verizon.net [206.46.170.107]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8BFE543D31 for ; Fri, 19 Nov 2004 19:35:13 +0000 (GMT) (envelope-from mteterin@250-217.customer.cloud9.net) Received: from corbulon.video-collage.com ([151.204.231.237]) by out007.verizon.netESMTP <20041119193512.MXYM1327.out007.verizon.net@corbulon.video-collage.com> for ; Fri, 19 Nov 2004 13:35:12 -0600 Received: from 250-217.customer.cloud9.net (195-11.customer.cloud9.net [168.100.195.11])iAJJWfLp072071 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 19 Nov 2004 14:32:42 -0500 (EST) (envelope-from mteterin@250-217.customer.cloud9.net) Received: from 250-217.customer.cloud9.net (mteterin@localhost [127.0.0.1]) iAJJWMKG028633 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 19 Nov 2004 14:32:22 -0500 (EST) (envelope-from mteterin@250-217.customer.cloud9.net) Received: (from mteterin@localhost)iAJJU05M028437; Fri, 19 Nov 2004 14:30:00 -0500 (EST) (envelope-from mteterin) Message-Id: <200411191930.iAJJU05M028437@250-217.customer.cloud9.net> Date: Fri, 19 Nov 2004 14:30:00 -0500 (EST) From: Mikhail Teterin To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 X-GNATS-Notify: lwall@netlabs.com cc: Larry Wall Subject: bin/74127: patch(1) may misapply hunks with too little context X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Nov 2004 19:40:33 -0000 >Number: 74127 >Category: bin >Synopsis: patch(1) may misapply hunks with too little context >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Nov 19 19:40:29 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Mikhail Teterin >Release: FreeBSD 5.3-STABLE i386 >Organization: Virtual Estates, Inc. >Environment: System: FreeBSD mi.us.murex.com 5.3-STABLE FreeBSD 5.3-STABLE #3: Tue Nov 9 17:40:11 EST 2004 mteterin@mi.us.murex.com:/meow/obj/misha/src/sys/Gigabyte i386 >Description: A patch produced with `diff -U0' or `-U1' may be misapplied if the file being patched changes (is of newer version) and the hunk is no longer applicable. patch(1) should fail loudly in this case, instead it sticks the new lines at the old location. >How-To-Repeat: Try applying this patch: --- l Mon Apr 3 20:00:28 2000 +++ l Fri May 5 10:01:58 2000 @@ -5,1 +5,1 @@ - set Log(compressProg) /usr/local/bin/gzip + set Log(compressProg) /usr/bin/gzip to this file: # This program is used to compress log files if {![info exists Log(compressProg)]} { set Log(compressProg) gzip } # Flush interval if {![info exists Log(flushInterval)]} { set Log(flushInterval) [expr {60 * 1000}] } # This is used to turn on an alternate debug log file if {![info exist Log(debug_log)]} { set Log(debug_log) 0 } It should not apply at all. Instead, one gets the reassuring: ``Hunk #1 succeeded at 5 with fuzz 1.'' and a botched file. >Fix: Use larger context, which is not always convenient. >Release-Note: >Audit-Trail: >Unformatted: