NetBSD Problem Report #49422

From ryo_on@yk.rim.or.jp  Thu Nov 27 10:43:56 2014
Return-Path: <ryo_on@yk.rim.or.jp>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 2398AA5864
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 27 Nov 2014 10:43:56 +0000 (UTC)
Message-Id: <20141127104352.5E2B630016669@mail.SiriusCloud.jp>
Date: Thu, 27 Nov 2014 19:43:52 +0900 (JST)
From: ryoon@NetBSD.org
Reply-To: ryoon@NetBSD.org
To: gnats-bugs@gnats.NetBSD.org
Subject: patch(1) cannot handle context diffs
X-Send-Pr-Version: 3.95

>Number:         49422
>Category:       bin
>Synopsis:       patch(1) cannot handle context diffs
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Nov 27 10:45:00 +0000 2014
>Closed-Date:    Fri Nov 28 00:11:08 +0000 2014
>Last-Modified:  Fri Nov 28 09:10:07 +0000 2014
>Originator:     Ryo ONODERA
>Release:        NetBSD 7.99.2
>Organization:

>Environment:


System: NetBSD angelcake.elements.tetera.org 7.99.2 NetBSD 7.99.2 (GENERIC) #0: Thu Nov 27 14:44:25 JST 2014 ryo_on@angelcake.elements.tetera.org:/usr/world/7.99/amd64/obj/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
patch(1) from today's NetBSD current (7.99.2) cannot handle context diffs
anymore. For example, please build pkgsrc/shells/bash.

>How-To-Repeat:
Build pkgsrc/shells/bash under today's NetBSD current.

>Fix:

The following fixes my problem.
Index: pch.c
===================================================================
RCS file: /cvsroot/src/usr.bin/patch/pch.c,v
retrieving revision 1.26
diff -u -r1.26 pch.c
--- pch.c	26 Nov 2014 00:31:32 -0000	1.26
+++ pch.c	27 Nov 2014 10:37:11 -0000
@@ -619,8 +619,8 @@
 					p_ptrn_lines = 0;
 					p_first = 1;
 				}
-				if (p_first <= LINENUM_MAX - p_ptrn_lines ||
-				    p_ptrn_lines <= LINENUM_MAX - 6)
+				if (p_first >= LINENUM_MAX - p_ptrn_lines ||
+				    p_ptrn_lines >= LINENUM_MAX - 6)
 					malformed();

 				/* we need this much at least */

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/49422 CVS commit: src/usr.bin/patch
Date: Thu, 27 Nov 2014 10:07:23 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Thu Nov 27 15:07:23 UTC 2014

 Modified Files:
 	src/usr.bin/patch: pch.c

 Log Message:
 PR/49422: Ryo ONODERA: patch(1) cannot handle context diffs


 To generate a diff of this commit:
 cvs rdiff -u -r1.26 -r1.27 src/usr.bin/patch/pch.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: ryoon@NetBSD.org
State-Changed-When: Fri, 28 Nov 2014 00:11:08 +0000
State-Changed-Why:
Patch is applied, and in pullup-7 queue.


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/49422 CVS commit: [netbsd-7] src/usr.bin/patch
Date: Fri, 28 Nov 2014 09:09:19 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Fri Nov 28 09:09:19 UTC 2014

 Modified Files:
 	src/usr.bin/patch [netbsd-7]: common.h pch.c

 Log Message:
 Pull up following revision(s) (requested by christos in ticket #270):
 	usr.bin/patch/common.h: revision 1.20
 	usr.bin/patch/pch.c: revision 1.26
 	usr.bin/patch/pch.c: revision 1.27
 Avoid coredumps when the linenumbers in the hunks turn negative.
 From OpenBSD.
 PR/49422: Ryo ONODERA: patch(1) cannot handle context diffs


 To generate a diff of this commit:
 cvs rdiff -u -r1.19 -r1.19.38.1 src/usr.bin/patch/common.h
 cvs rdiff -u -r1.25 -r1.25.8.1 src/usr.bin/patch/pch.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.