Bug 22351

Summary: sed(1) fails with backslash on buffer boundary in subst expressions
Product: Base System Reporter: stefan.duerholt <stefan.duerholt>
Component: binAssignee: Brian Feldman <green>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 3.5-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description stefan.duerholt 2000-10-27 17:50:00 UTC
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.

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 $"
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
Comment 1 Juli Mallett freebsd_committer freebsd_triage 2002-06-27 01:38:24 UTC
State Changed
From-To: open->suspended

Over to Brian since I think he fixed this;  suspend it, he can close it. 


Comment 2 Juli Mallett freebsd_committer freebsd_triage 2002-06-27 01:38:24 UTC
Responsible Changed
From-To: freebsd-bugs->green

Over to Brian since I think he fixed this;  suspend it, he can close it.
Comment 3 Tim Robbins freebsd_committer freebsd_triage 2004-08-22 10:38:31 UTC
State Changed
From-To: suspended->closed

This has been fixed for a long time.