summaryrefslogtreecommitdiffstats
path: root/usr.bin/sed
diff options
context:
space:
mode:
authorhrs <hrs@FreeBSD.org>2008-11-09 01:10:21 +0000
committerhrs <hrs@FreeBSD.org>2008-11-09 01:10:21 +0000
commit9fe9cedf42d903b585afbf27d6563b029d1b2873 (patch)
tree8a44c6445bae92cad188471edb02b27f5fb0dddc /usr.bin/sed
parentc3eca8b8ccc2dc085e9ca65fd475705d81b1b09a (diff)
downloadFreeBSD-src-9fe9cedf42d903b585afbf27d6563b029d1b2873.zip
FreeBSD-src-9fe9cedf42d903b585afbf27d6563b029d1b2873.tar.gz
Add workaround for a back reference when no corresponding
parenthesized subexpression is defined. For example, the following command line caused unexpected behavior like segmentation fault: % echo test | sed -e 's/test/\1/' PR: bin/126682 MFC after: 1 week
Diffstat (limited to 'usr.bin/sed')
-rw-r--r--usr.bin/sed/compile.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/usr.bin/sed/compile.c b/usr.bin/sed/compile.c
index 2e3a2ce..a5416ee 100644
--- a/usr.bin/sed/compile.c
+++ b/usr.bin/sed/compile.c
@@ -324,9 +324,17 @@ nonsel: /* Now parse the command */
if (p == NULL)
errx(1,
"%lu: %s: unterminated substitute pattern", linenum, fname);
+
+ /* Compile RE with no case sensitivity temporarily */
+ if (*re == '\0')
+ cmd->u.s->re = NULL;
+ else
+ cmd->u.s->re = compile_re(re, 0);
--p;
p = compile_subst(p, cmd->u.s);
p = compile_flags(p, cmd->u.s);
+
+ /* Recompile RE with case sensitivity from "I" flag if any */
if (*re == '\0')
cmd->u.s->re = NULL;
else
OpenPOWER on IntegriCloud