Subject: sed cannot substitute more than 4kB
To: None <tech-userlevel@netbsd.org>
From: Emmanuel Dreyfus <manu@netbsd.org>
List: tech-userlevel
Date: 07/09/2004 08:23:08
Hi
Here is a sed bug:
echo "X"|sed "s/X/`jot -sx -bx 2048`/"
i.e.: it cannot substitute by a string bigger than 4096kB
Here is a fix:
Index: compile.c
===================================================================
RCS file: /cvsroot/src/usr.bin/sed/compile.c,v
retrieving revision 1.28
diff -U4 -r1.28 compile.c
--- compile.c 13 Jun 2004 08:34:31 -0000 1.28
+++ compile.c 9 Jul 2004 08:09:17 -0000
@@ -543,9 +543,9 @@
}
size += sp - op;
if (asize - size < _POSIX2_LINE_MAX + 1) {
asize *= 2;
- text = xmalloc(asize);
+ text = xrealloc(text, asize);
}
} while (cu_fgets(p = lbuf, sizeof(lbuf)));
err(COMPILE, "unterminated substitute in regular expression");
/* NOTREACHED */
Is it okay to commit that? To pull-it up to 2.0 and 1.6?
--
Emmanuel Dreyfus
manu@netbsd.org