Fix gcc sprintf warnings
Gcc 9 has become more vocal with sprintf buffer overflow checking. Remove these sprintf warnings by changing the offending calls to a snprintf wrapper that will explicitly check the result.
This commit is contained in:
@@ -451,7 +451,7 @@ curses_choose_character()
|
||||
}
|
||||
|
||||
prompt[count_off] = '\0';
|
||||
sprintf(choice, "%s%c", tmpchoice, '\033');
|
||||
Snprintf(choice, sizeof(choice), "%s%c", tmpchoice, '\033');
|
||||
if (strchr(tmpchoice, 't')) { /* Tutorial mode */
|
||||
mvaddstr(0, 1, "New? Press t to enter a tutorial.");
|
||||
}
|
||||
|
||||
@@ -961,10 +961,10 @@ tty_player_selection()
|
||||
Sprintf(plbuf, " %s", genders[GEND].adj);
|
||||
else
|
||||
*plbuf = '\0'; /* omit redundant gender */
|
||||
Sprintf(pbuf, "%s, %s%s %s %s", g.plname, aligns[ALGN].adj, plbuf,
|
||||
races[RACE].adj,
|
||||
(GEND == 1 && roles[ROLE].name.f) ? roles[ROLE].name.f
|
||||
: roles[ROLE].name.m);
|
||||
Snprintf(pbuf, sizeof(pbuf), "%s, %s%s %s %s", g.plname,
|
||||
aligns[ALGN].adj, plbuf, races[RACE].adj,
|
||||
(GEND == 1 && roles[ROLE].name.f) ? roles[ROLE].name.f
|
||||
: roles[ROLE].name.m);
|
||||
add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, pbuf,
|
||||
MENU_ITEMFLAGS_NONE);
|
||||
/* blank separator */
|
||||
|
||||
Reference in New Issue
Block a user