From owner-freebsd-bugs Fri Oct 27 9:50: 8 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 2A46337B4C5 for ; Fri, 27 Oct 2000 09:50:01 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id JAA99754; Fri, 27 Oct 2000 09:50:01 -0700 (PDT) (envelope-from gnats@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 To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: bin/22351: sed(1) fails with backslash on buffer boundary in subst expressions Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 22351 >Category: bin >Synopsis: sed(1) fails with backslash on buffer boundary in subst expressions >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Oct 27 09:50:00 PDT 2000 >Closed-Date: >Last-Modified: >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: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message