From 65d6c98fc2973b32ffd4c393f3fcfaf5e3e408c1 Mon Sep 17 00:00:00 2001 From: Zeex Date: Sun, 22 Sep 2019 17:23:26 +0600 Subject: [PATCH] Fix GCC warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit source/compiler/sc1.c: In function ‘check_tagmismatch_multiple’: source/compiler/sc1.c:3482:40: warning: ‘"’ directive writing 1 byte into a region of size between 0 and 4094 [-Wformat-overflow=] sprintf(formal_tagnames,"%s\"%s\"",formal_tagnames,(tagsym!=NULL) ? tagsym->name : "-unknown-"); ^~ source/compiler/sc1.c:3482:9: note: ‘sprintf’ output 3 or more bytes (assuming 4097) into a destination of size 4095 sprintf(formal_tagnames,"%s\"%s\"",formal_tagnames,(tagsym!=NULL) ? tagsym->name : "-unknown-"); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- source/compiler/sc1.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index 1314e52..4ef25b8 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -3469,8 +3469,9 @@ SC_FUNC void check_tagmismatch_multiple(int formaltags[],int numtags,int actualt if (!checktag(formaltags, numtags, actualtag)) { int i; constvalue *tagsym; - char formal_tagnames[sLINEMAX]="",actual_tagname[sNAMEMAX+2]="none (\"_\")"; + char formal_tagnames[sLINEMAX+1]="",actual_tagname[sNAMEMAX+2]="none (\"_\")"; int notag_allowed=FALSE,add_comma=FALSE; + size_t size; for (i=0; iname : "-unknown-"); + size=snprintf(formal_tagnames, + sizeof(formal_tagnames), + "%s\"%s\"", + formal_tagnames, + (tagsym!=NULL) ? tagsym->name : "-unknown-"); + if (size>=sizeof(formal_tagnames)) + break; } else { notag_allowed=TRUE; } /* if */