Subject: bin/24234: sed argument parsing bug
To: None <gnats-bugs@gnats.netbsd.org>
From: None <kay@kaynet.or.jp>
List: netbsd-bugs
Date: 01/25/2004 17:43:02
>Number:         24234
>Category:       bin
>Synopsis:       sed argument parsing bug
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 25 08:44:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Keisuke YOSHIDA
>Release:        NetBSD 1.6ZH
>Organization:
Keisuke YOSHIDA, Kawasaki, Kanagawa, Japan (kay@kaynet.or.jp)
My home page http://www.kaynet.or.jp/~kay/ (Japanese only)
>Environment:
gaia# ldd ./sed
./sed:
         -lc.12 => /usr/lib/libc.so.12
gaia# ident ./sed
./sed:
     $NetBSD: crt0.c,v 1.3 2003/11/28 23:25:54 fvdl Exp $
     $NetBSD: compile.c,v 1.25 2003/08/07 11:15:49 agc Exp $
     $NetBSD: main.c,v 1.15 2003/10/16 12:11:12 grant Exp $
     $NetBSD: misc.c,v 1.8 2003/08/07 11:15:50 agc Exp $
     $NetBSD: process.c,v 1.35 2003/11/07 04:44:57 itojun Exp $
System: NetBSD gaia 1.6ZH NetBSD 1.6ZH (GAIA.MP) #0: Sat Jan 17 20:51:10 JST 2004  root@gaia:/sys/arch/amd64/compile/GAIA.MP amd64
Architecture: amd64
Machine: x86_64
>Description:
>How-To-Repeat:
gaia# ./sed -e 's,AA,1234567,1' -e 's,LIMIN,AA,1'
sed: 1: "s,LIMIN,AA,1": more than one number or 'g' in substitute flags
>Fix:
Index: compile.c
===================================================================
RCS file: /export/home3/cvsroot/src/usr.bin/sed/compile.c,v
retrieving revision 1.25
diff -u -r1.25 compile.c
--- compile.c	7 Aug 2003 11:15:49 -0000	1.25
+++ compile.c	25 Jan 2004 08:25:25 -0000
@@ -570,6 +570,7 @@
 			gn = 1;
 			/* XXX Check for overflow */
 			s->n = (int)strtol(p, &p, 10);
+			p--;
 			break;
 		case 'w':
 			p++;

>Release-Note:
>Audit-Trail:
>Unformatted: