Author: hrs
Date: Wed Nov 19 18:06:29 2008
New Revision: 185100
URL: http://svn.freebsd.org/changeset/base/185100

Log:
  MFC: 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/'
  
  Approved by:  re (kib)
  PR:           bin/126682

Modified:
  stable/7/usr.bin/sed/   (props changed)
  stable/7/usr.bin/sed/compile.c

Modified: stable/7/usr.bin/sed/compile.c
==============================================================================
--- stable/7/usr.bin/sed/compile.c      Wed Nov 19 17:34:28 2008        
(r185099)
+++ stable/7/usr.bin/sed/compile.c      Wed Nov 19 18:06:29 2008        
(r185100)
@@ -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
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to