summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2008-10-09 16:40:56 +0000
committermillert <millert@openbsd.org>2008-10-09 16:40:56 +0000
commitc510cb78f7e213078fd055e9d62e89d2cc660f3f (patch)
tree9d402b09c78b59550ee9b41b2101643c9985dcf8
parentChange sb_timeo to unsigned, so that even if some calculation (ie. n * HZ) (diff)
downloadwireguard-openbsd-c510cb78f7e213078fd055e9d62e89d2cc660f3f.tar.xz
wireguard-openbsd-c510cb78f7e213078fd055e9d62e89d2cc660f3f.zip
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;