From nobody@FreeBSD.ORG  Fri Oct 27 09:46:33 2000
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id AC82F37B479; Fri, 27 Oct 2000 09:46:33 -0700 (PDT)
Message-Id: <20001027164633.AC82F37B479@hub.freebsd.org>
Date: Fri, 27 Oct 2000 09:46:33 -0700 (PDT)
From: stefan.duerholt@t-online.de
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@FreeBSD.org
Subject: sed(1) fails with backslash on buffer boundary in subst expressions
X-Send-Pr-Version: www-1.0

>Number:         22351
>Category:       bin
>Synopsis:       sed(1) fails with backslash on buffer boundary in subst expressions
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    green
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 27 09:50:00 PDT 2000
>Closed-Date:    Sun Aug 22 09:38:49 GMT 2004
>Last-Modified:  Sun Aug 22 09:38:49 GMT 2004
>Originator:     Stefan Duerholt
>Release:        3.5-RELEASE, 4.0-RELEASE
>Organization:
>Environment:
Different versions of FreeBSD (3.5-RELEASE, 4.0-RELEASE), also
CVS checked out from -CURRENT
>Description:
In an substitution command like

$ sed -e "s/X/xxxx ... xxxx\\zz/",

where the first '\' is exacly on character position 2048 (i.e.
exactly 2043 'x' in this example), sed fails to compile the
substitution expression and aborts with

sed: 1: "s/X/xxxxxxxxxxxxxxxxxxx ...": \ not defined in the RE

The same with -f and a file containing the line.
Also with multiple of 2048.

This causes (for example) ruby-1.6.1 to fail during make, as autoconf
generates substitution expressions with such long lines.
>How-To-Repeat:
if you type:
$ sed -e `perl -le 'print "s/X/","x"x2043,"\\\\zz/"'`

it fails with:
sed: 1: "s/X/xxxxxxxxxxxxxxxxxxx ...": \ not defined in the RE

>Fix:
Apply this patch to src/usr.bin/sed/compile.c
"$FreeBSD: src/usr.bin/sed/compile.c,v 1.14 2000/03/19 19:41:52 green Exp $"

--- compile.c.orig      Sun Mar 19 19:41:52 2000
+++ compile.c   Fri Oct 27 16:10:39 2000
@@ -471,13 +471,16 @@
                op = sp = text + size;
                for (; *p; p++) {
                        if (*p == '\\') {
-                               p++;
+                               if (*++p == '\0') {
+                                       if (cu_fgets(lbuf, sizeof(lbuf), &more))
+                                               p = lbuf;
+                               }
                                if (strchr("123456789", *p) != NULL) {
                                        *sp++ = '\\';


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->suspended 
State-Changed-By: jmallett 
State-Changed-When: Wed Jun 26 17:38:24 PDT 2002 
State-Changed-Why:  
Over to Brian since I think he fixed this;  suspend it, he can close it. 


Responsible-Changed-From-To: freebsd-bugs->green 
Responsible-Changed-By: jmallett 
Responsible-Changed-When: Wed Jun 26 17:38:24 PDT 2002 
Responsible-Changed-Why:  
Over to Brian since I think he fixed this;  suspend it, he can close it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=22351 
State-Changed-From-To: suspended->closed 
State-Changed-By: tjr 
State-Changed-When: Sun Aug 22 09:38:31 GMT 2004 
State-Changed-Why:  
This has been fixed for a long time. 

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