summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2008-10-09 16:40:57 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2008-10-09 16:40:57 +0000
commit3bbbc6c516cdd3ad6089b50d0c285630171e4448 (patch)
tree4c643cba0832b032f9b9fe956e2a935965dd1927
parent5c38636e40215dcc90f390ee647e46409b3273f2 (diff)
In compile_subst(), adjust for the fact that the initial buffer
that is passed in may now be larger than _POSIX2_LINE_MAX. Thanks to pedro@ for the test case. OK pedro@
-rw-r--r--usr.bin/sed/compile.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/sed/compile.c b/usr.bin/sed/compile.c
index b8ada82c4f3..082622b15aa 100644
--- a/usr.bin/sed/compile.c
+++ b/usr.bin/sed/compile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: compile.c,v 1.25 2008/10/08 17:26:47 millert Exp $ */
+/* $OpenBSD: compile.c,v 1.26 2008/10/09 16:40:56 millert Exp $ */
/*-
* Copyright (c) 1992 Diomidis Spinellis.
@@ -35,7 +35,7 @@
#ifndef lint
/* from: static char sccsid[] = "@(#)compile.c 8.2 (Berkeley) 4/28/95"; */
-static const char rcsid[] = "$OpenBSD: compile.c,v 1.25 2008/10/08 17:26:47 millert Exp $";
+static const char rcsid[] = "$OpenBSD: compile.c,v 1.26 2008/10/09 16:40:56 millert Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -458,7 +458,7 @@ static char *
compile_subst(char *p, struct s_subst *s)
{
static char *lbuf;
- static size_t len = _POSIX2_LINE_MAX;
+ static size_t len;
int asize, ref, size;
char c, *text, *op, *sp;
int sawesc = 0;
@@ -470,6 +470,9 @@ compile_subst(char *p, struct s_subst *s)
if (c == '\0')
return (NULL);
+ len = strlen(p);
+ if (len < _POSIX2_LINE_MAX)
+ len = _POSIX2_LINE_MAX;
s->maxbref = 0;
s->linenum = linenum;
asize = 2 * len + 1;