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 i = 0;
|
||||||
int c;
|
int c;
|
||||||
int quote = 0;
|
int quote = 0;
|
||||||
while((c = input()) != EOF){
|
while(i < sizeof(x) - 1 && (c = input()) != EOF){
|
||||||
if(quote) {
|
if(quote) {
|
||||||
x[i++] = c;
|
x[i++] = c;
|
||||||
quote = 0;
|
quote = 0;
|
||||||
@@ -110,6 +110,8 @@ getstring(void)
|
|||||||
}
|
}
|
||||||
x[i] = '\0';
|
x[i] = '\0';
|
||||||
yylval.string = strdup(x);
|
yylval.string = strdup(x);
|
||||||
|
if (yylval.string)
|
||||||
|
err(1, "malloc");
|
||||||
return STRING;
|
return STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user