From 3bbbc6c516cdd3ad6089b50d0c285630171e4448 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 9 Oct 2008 16:40:57 +0000 Subject: 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@ --- usr.bin/sed/compile.c | 9 ++++++--- 1 file 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 @@ -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; -- cgit v1.2.3