catch buffer overrun and check allocation errors
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15142 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user