From e4e9f2151fdb31200060dd397ce53d6f5a9179fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Mon, 16 May 2005 08:52:36 +0000 Subject: [PATCH] catch buffer overrun and check allocation errors git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15142 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/com_err/lex.l | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/com_err/lex.l b/lib/com_err/lex.l index 921945cdf..f23ae5d7e 100644 --- a/lib/com_err/lex.l +++ b/lib/com_err/lex.l @@ -89,7 +89,7 @@ getstring(void) int i = 0; int c; int quote = 0; - while((c = input()) != EOF){ + while(i < sizeof(x) - 1 && (c = input()) != EOF){ if(quote) { x[i++] = c; quote = 0; @@ -110,6 +110,8 @@ getstring(void) } x[i] = '\0'; yylval.string = strdup(x); + if (yylval.string) + err(1, "malloc"); return STRING; }