NetBSD Problem Report #54620

From www@netbsd.org  Wed Oct 16 09:35:05 2019
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id B6B8E7A20B
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 16 Oct 2019 09:35:04 +0000 (UTC)
Message-Id: <20191016093503.D1B487A25B@mollari.NetBSD.org>
Date: Wed, 16 Oct 2019 09:35:03 +0000 (UTC)
From: coypu@sdf.org
Reply-To: coypu@sdf.org
To: gnats-bugs@NetBSD.org
Subject: patch(1) has issues with long lines
X-Send-Pr-Version: www-1.0

>Number:         54620
>Category:       bin
>Synopsis:       patch(1) has issues with long lines
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    cjep
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 16 09:40:00 +0000 2019
>Closed-Date:    Tue May 25 11:46:38 +0000 2021
>Last-Modified:  Tue May 25 11:46:38 +0000 2021
>Originator:     coypu
>Release:        NetBSD 9.99.15
>Organization:
>Environment:
NetBSD planets 9.99.15 NetBSD 9.99.15 (GENERIC) #1: Fri Oct 11 23:50:23 IDT 2019  fly@planets:/cvs/obj/sys/arch/amd64/compile/GENERIC amd64

>Description:
Unfortunately there's a very real scenario for this happening: trying to patch JSON files in pkgsrc.

It errors like:

patch: **** malformed patch at line 5: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa


>How-To-Repeat:
Here's a test case. It works if changing 10000s to 1000s.

#!/bin/sh

printf %10s |tr " " "a" > longlines 2>/dev/null

cat << EOF > longlines.patch
--- ./longlines.orig	2019-10-16 09:25:30.667656644 +0000
+++ ./longlines
@@ -1 +1 @@
EOF

printf -- "-"%10s"\n" |tr " " "a" >> longlines.patch 2>/dev/null
printf -- "+"%10s |tr " " "b" >> longlines.patch 2>/dev/null

patch longlines < longlines.patch
>Fix:

>Release-Note:

>Audit-Trail:
From: coypu@sdf.org
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/54620: patch(1) has issues with long lines
Date: Wed, 16 Oct 2019 11:21:39 +0000

 Oops, the failing variant is with "10000s" :-)

 #!/bin/sh

 printf %10000s |tr " " "a" > longlines 2>/dev/null

 cat << EOF > longlines.patch
 --- ./longlines.orig	2019-10-16 09:25:30.667656644 +0000
 +++ ./longlines
 @@ -1 +1 @@
 EOF

 printf -- "-"%10000s"\n" |tr " " "a" >> longlines.patch 2>/dev/null
 printf -- "+"%10000s |tr " " "b" >> longlines.patch 2>/dev/null

 patch longlines < longlines.patch

From: coypu@sdf.org
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/54620: patch(1) has issues with long lines
Date: Wed, 4 Dec 2019 21:23:50 +0000

 looks like openbsd recently committed a fix for their patch.
 https://v4.freshbsd.org/commit/openbsd/src/1Wl50W6O3FLZ1Et1

Responsible-Changed-From-To: bin-bug-people->cjep
Responsible-Changed-By: cjep@NetBSD.org
Responsible-Changed-When: Tue, 25 May 2021 11:19:41 +0000
Responsible-Changed-Why:
Take


State-Changed-From-To: open->analyzed
State-Changed-By: cjep@NetBSD.org
State-Changed-When: Tue, 25 May 2021 11:19:41 +0000
State-Changed-Why:
Analysed the approach and am working on a patch.


From: "Chris Pinnock" <cjep@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54620 CVS commit: src/usr.bin/patch
Date: Tue, 25 May 2021 11:26:00 +0000

 Module Name:	src
 Committed By:	cjep
 Date:		Tue May 25 11:25:59 UTC 2021

 Modified Files:
 	src/usr.bin/patch: common.h inp.c patch.c pch.c util.c

 Log Message:
 As per OpenBSD, use malloc for the line buffer. Fixes the known issue
 with long lines and makes our ATF test suite pass fully.
 Closes PR bin/54620 from coypu who suggested the approach.
 Reviewed by christos.


 To generate a diff of this commit:
 cvs rdiff -u -r1.21 -r1.22 src/usr.bin/patch/common.h
 cvs rdiff -u -r1.26 -r1.27 src/usr.bin/patch/inp.c
 cvs rdiff -u -r1.31 -r1.32 src/usr.bin/patch/patch.c src/usr.bin/patch/pch.c
 cvs rdiff -u -r1.29 -r1.30 src/usr.bin/patch/util.c

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

State-Changed-From-To: analyzed->closed
State-Changed-By: cjep@NetBSD.org
State-Changed-When: Tue, 25 May 2021 11:46:38 +0000
State-Changed-Why:
Patch commited to current.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.