Merge fixes from 'NetHack-3.6' into NetHack-3.7-Jan2020

This commit is contained in:
nhmall
2020-01-20 21:33:20 -05:00
10 changed files with 73 additions and 17 deletions

View File

@@ -1162,7 +1162,7 @@ VA_DECL(const char *, s)
if (iflags.window_inited)
end_screen();
buf[0] = '\n';
(void) vsprintf(&buf[1], s, VA_ARGS);
(void) vsnprintf(&buf[1], sizeof buf - 1, s, VA_ARGS);
msmsg(buf);
really_move_cursor();
VA_END();
@@ -1980,7 +1980,7 @@ VA_DECL(const char *, fmt)
char buf[ROWNO * COLNO]; /* worst case scenario */
VA_START(fmt);
VA_INIT(fmt, const char *);
Vsprintf(buf, fmt, VA_ARGS);
(void) vsnprintf(buf, sizeof buf, fmt, VA_ARGS);
if (redirect_stdout)
fprintf(stdout, "%s", buf);
else {

View File

@@ -241,11 +241,11 @@ VA_DECL(const char *, s)
end_screen();
if (WINDOWPORT("tty")) {
buf[0] = '\n';
(void) vsprintf(&buf[1], s, VA_ARGS);
(void) vsnprintf(&buf[1], sizeof buf - (1 + sizeof "\n"), s, VA_ARGS);
Strcat(buf, "\n");
msmsg(buf);
} else {
(void) vsprintf(buf, s, VA_ARGS);
(void) vsnprintf(buf, sizeof buf - sizeof "\n", s, VA_ARGS);
Strcat(buf, "\n");
raw_printf(buf);
}