binpac: address linter warnings about use of sprintf()

This commit is contained in:
Vern Paxson 2022-12-13 15:14:15 -08:00 committed by Tim Wojtulewicz
parent d5f2c9c3a8
commit 49a96f5216

View file

@ -1068,17 +1068,17 @@ const ID* current_decl_id = 0;
int yyerror(const char msg[]) int yyerror(const char msg[])
{ {
char* msgbuf = auto n = strlen(msg) + yyleng + 64;
new char[strlen(msg) + yyleng + 64]; char* msgbuf = new char[n];
if ( ! yychar || ! yytext || yytext[0] == '\0' ) if ( ! yychar || ! yytext || yytext[0] == '\0' )
sprintf(msgbuf, "%s, at end of file", msg); snprintf(msgbuf, n, "%s, at end of file", msg);
else if ( yytext[0] == '\n' ) else if ( yytext[0] == '\n' )
sprintf(msgbuf, "%s, on previous line", msg); snprintf(msgbuf, n, "%s, on previous line", msg);
else else
sprintf(msgbuf, "%s, at or near \"%s\"", msg, yytext); snprintf(msgbuf, n, "%s, at or near \"%s\"", msg, yytext);
/* /*
extern int column; extern int column;