From nobody@FreeBSD.org  Wed Mar 27 12:06:56 2002
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 8425837B41D
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 27 Mar 2002 12:06:55 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.6/8.11.6) id g2RK6te22171;
	Wed, 27 Mar 2002 12:06:55 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200203272006.g2RK6te22171@freefall.freebsd.org>
Date: Wed, 27 Mar 2002 12:06:55 -0800 (PST)
From: John Fitzgibbon <fitz@jfitz.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: sed misbehaves with 2044 char substitute patterns
X-Send-Pr-Version: www-1.0

>Number:         36383
>Category:       bin
>Synopsis:       sed misbehaves with 2044 char substitute patterns
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 27 12:10:01 PST 2002
>Closed-Date:    Sat Jun 29 22:33:27 PDT 2002
>Last-Modified:  Sat Jun 29 22:33:27 PDT 2002
>Originator:     John Fitzgibbon
>Release:        4.5-STABLE
>Organization:
>Environment:
FreeBSD joy.jfitz.com 4.5-STABLE FreeBSD 4.5-STABLE #0: Thu Mar  7 11:17:05 PST 2002     fitz@joy.jfitz.com:/usr/obj/usr/src/sys/JOY  i386
>Description:
%sed `perl -e 'print "s/"; print "x" x 2044; print "//g"'` test.dat
%sed `perl -e 'print "s/"; print "x" x 2043; print "/y/g"'` test.dat
%sed `perl -e 'print "s/"; print "x" x 2042; print "/yy/g"'` test.dat

The commands above all give no output, regardless of the input file. Any other total count of x's and y's in the substitute pattern will print the file test.dat without modification, (up to 2046, at which point sed appears to begin truncating the input):

%sed `perl -e 'print "s/"; print "x" x 2046; print "//g"'` test.dat
sed: 1: "s/xxxxxxxxxxxxxxxxxxxxx ...": unterminated substitute pattern

It's a little strange that the pattern seems to work for 2045 characters, but not 2044 or 2046.


>How-To-Repeat:

>Fix:
      
>Release-Note:
>Audit-Trail:

From: Tim Robbins <tjr@FreeBSD.ORG>
To: bug-followup@FreeBSD.ORG
Cc: John Fitzgibbon <fitz@jfitz.com>
Subject: Re: bin/36383: sed misbehaves with 2044 char substitute patterns
Date: Sat, 22 Jun 2002 12:14:47 +1000

 Does this problem still exist? I cannot reproduce it 4.6 or -CURRENT.
 What is in test.dat? Is there an over-long line in it, a missing newline
 at EOF, or something special?
 
 
 Tim

From: "Danny J. Zerkel" <dzerkel@columbus.rr.com>
To: freebsd-gnats-submit@FreeBSD.org, fitz@jfitz.com
Cc:  
Subject: Re: bin/36383: sed misbehaves with 2044 char substitute patterns
Date: Sat, 22 Jun 2002 08:54:02 -0400

 In current, the first three examples appear to work as expected.
 At 2046, and above, you get the "unterminated substitute pattern"
 error due to the pattern being longer than 2 * POSIX_LINE_LEN
 (= 2048) when the delimiters are included.  So this looks normal.
 
 -- Danny J. Zerkel
 dzerkel@columbus.rr.com
 

From: "John Fitzgibbon" <fitz@jfitz.com>
To: "Tim Robbins" <tjr@FreeBSD.ORG>, <bug-followup@FreeBSD.ORG>
Cc:  
Subject: Re: bin/36383: sed misbehaves with 2044 char substitute patterns
Date: Sun, 23 Jun 2002 15:40:07 -0700

 I cvsup'd to 4.6 and the problem seems to be fixed.
 
 The content of "test.dat" does not affect the outcome.
 John Fitzgibbon.
 
 ----- Original Message ----- 
 From: "Tim Robbins" <tjr@FreeBSD.ORG>
 To: <bug-followup@FreeBSD.ORG>
 Cc: "John Fitzgibbon" <fitz@jfitz.com>
 Sent: Friday, June 21, 2002 7:14 PM
 Subject: Re: bin/36383: sed misbehaves with 2044 char substitute patterns
 
 
 Does this problem still exist? I cannot reproduce it 4.6 or -CURRENT.
 What is in test.dat? Is there an over-long line in it, a missing newline
 at EOF, or something special?
 
 
 Tim
 
 
State-Changed-From-To: open->closed 
State-Changed-By: tjr 
State-Changed-When: Sat Jun 29 22:31:48 PDT 2002 
State-Changed-Why:  
Originator says that the problem is fixed in 4.6, I cannot reproduce the 
problem on 4.6 or -CURRENT. Thanks for reporting this interestin bug, though. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=36383 
>Unformatted:
