Internal: Prevent possible buffer overrun

This commit is contained in:
Wilson Snyder 2012-04-05 21:46:03 -04:00
parent 6a38d3bcf3
commit ab9a2b1728
1 changed files with 4 additions and 2 deletions

View File

@ -112,11 +112,13 @@ void yyerror(const char* errmsg) {
}
void yyerrorf(const char* format, ...) {
char msg[1024];
const int maxlen = 2000;
char msg[maxlen];
va_list ap;
va_start(ap,format);
vsprintf(msg,format,ap);
vsnprintf(msg,maxlen,format,ap);
msg[maxlen-1] = '\0';
va_end(ap);
yyerror(msg);