From 49a96f5216b7038591fe8f98bcf9013b622f2eb1 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Tue, 13 Dec 2022 15:14:15 -0800 Subject: [PATCH] binpac: address linter warnings about use of sprintf() --- tools/binpac/src/pac_parse.yy | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/binpac/src/pac_parse.yy b/tools/binpac/src/pac_parse.yy index 178af0604e..b1172c307c 100644 --- a/tools/binpac/src/pac_parse.yy +++ b/tools/binpac/src/pac_parse.yy @@ -1068,17 +1068,17 @@ const ID* current_decl_id = 0; int yyerror(const char msg[]) { - char* msgbuf = - new char[strlen(msg) + yyleng + 64]; + auto n = strlen(msg) + yyleng + 64; + char* msgbuf = new char[n]; 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' ) - sprintf(msgbuf, "%s, on previous line", msg); + snprintf(msgbuf, n, "%s, on previous line", msg); else - sprintf(msgbuf, "%s, at or near \"%s\"", msg, yytext); + snprintf(msgbuf, n, "%s, at or near \"%s\"", msg, yytext); /* extern int column;