Merge fixes from 'NetHack-3.6' into NetHack-3.7-Jan2020
This commit is contained in:
@@ -610,7 +610,11 @@ VA_DECL(const char *, str)
|
||||
{
|
||||
char buf[BUFSZ];
|
||||
|
||||
#if !defined(NO_VSNPRINTF)
|
||||
(void) vsnprintf(buf, sizeof buf, str, VA_ARGS);
|
||||
#else
|
||||
Vsprintf(buf, str, VA_ARGS);
|
||||
#endif
|
||||
raw_print(buf);
|
||||
paniclog("panic", buf);
|
||||
}
|
||||
|
||||
32
src/pline.c
32
src/pline.c
@@ -121,6 +121,9 @@ VA_DECL(const char *, line)
|
||||
char pbuf[BIGBUFSZ]; /* will get chopped down to BUFSZ-1 if longer */
|
||||
int ln;
|
||||
int msgtyp;
|
||||
#if !defined(NO_VSNPRINTF)
|
||||
int vlen = 0;
|
||||
#endif
|
||||
boolean no_repeat;
|
||||
/* Do NOT use VA_START and VA_END in here... see above */
|
||||
|
||||
@@ -134,7 +137,16 @@ VA_DECL(const char *, line)
|
||||
return;
|
||||
|
||||
if (index(line, '%')) {
|
||||
#if !defined(NO_VSNPRINTF)
|
||||
vlen = vsnprintf(pbuf, sizeof pbuf, line, VA_ARGS);
|
||||
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED) && defined(DEBUG)
|
||||
if (vlen >= (int) sizeof pbuf)
|
||||
panic("%s: truncation of buffer at %zu of %d bytes",
|
||||
"pline", sizeof pbuf, vlen);
|
||||
#endif
|
||||
#else
|
||||
Vsprintf(pbuf, line, VA_ARGS);
|
||||
#endif
|
||||
line = pbuf;
|
||||
}
|
||||
if ((ln = (int) strlen(line)) > BUFSZ - 1) {
|
||||
@@ -443,7 +455,11 @@ VA_DECL(const char *, line)
|
||||
/* Do NOT use VA_START and VA_END in here... see above */
|
||||
|
||||
if (index(line, '%')) {
|
||||
#if !defined(NO_VSNPRINTF)
|
||||
(void) vsnprintf(pbuf, sizeof pbuf, line, VA_ARGS);
|
||||
#else
|
||||
Vsprintf(pbuf, line, VA_ARGS);
|
||||
#endif
|
||||
line = pbuf;
|
||||
}
|
||||
if ((int) strlen(line) > BUFSZ - 1) {
|
||||
@@ -473,7 +489,11 @@ VA_DECL(const char *, s)
|
||||
panic("impossible called impossible");
|
||||
|
||||
g.program_state.in_impossible = 1;
|
||||
#if !defined(NO_VSNPRINTF)
|
||||
(void) vsnprintf(pbuf, sizeof pbuf, s, VA_ARGS);
|
||||
#else
|
||||
Vsprintf(pbuf, s, VA_ARGS);
|
||||
#endif
|
||||
pbuf[BUFSZ - 1] = '\0'; /* sanity */
|
||||
paniclog("impossible", pbuf);
|
||||
if (iflags.debug_fuzzer)
|
||||
@@ -570,9 +590,21 @@ config_error_add
|
||||
VA_DECL(const char *, str)
|
||||
#endif /* ?(USE_STDARG || USE_VARARG) */
|
||||
{ /* start of vconf...() or of nested block in USE_OLDARG's conf...() */
|
||||
#if !defined(NO_VSNPRINTF)
|
||||
int vlen = 0;
|
||||
#endif
|
||||
char buf[BIGBUFSZ]; /* will be chopped down to BUFSZ-1 if longer */
|
||||
|
||||
#if !defined(NO_VSNPRINTF)
|
||||
vlen = vsnprintf(buf, sizeof buf, str, VA_ARGS);
|
||||
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED) && defined(DEBUG)
|
||||
if (vlen >= (int) sizeof buf)
|
||||
panic("%s: truncation of buffer at %zu of %d bytes",
|
||||
"config_error_add", sizeof buf, vlen);
|
||||
#endif
|
||||
#else
|
||||
Vsprintf(buf, str, VA_ARGS);
|
||||
#endif
|
||||
buf[BUFSZ - 1] = '\0';
|
||||
config_erradd(buf);
|
||||
|
||||
|
||||
@@ -997,6 +997,7 @@ int uid;
|
||||
* print selected parts of score list.
|
||||
* argc >= 2, with argv[0] untrustworthy (directory names, et al.),
|
||||
* and argv[1] starting with "-s".
|
||||
* caveat: some shells might allow argv elements to be arbitrarily long.
|
||||
*/
|
||||
void
|
||||
prscore(argc, argv)
|
||||
|
||||
@@ -241,7 +241,8 @@ void
|
||||
choose_windows(s)
|
||||
const char *s;
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
char *tmps = 0;
|
||||
|
||||
for (i = 0; winchoices[i].procs; i++) {
|
||||
if ('+' == winchoices[i].procs->name[0])
|
||||
@@ -267,9 +268,22 @@ const char *s;
|
||||
windowprocs.win_wait_synch = def_wait_synch;
|
||||
|
||||
if (!winchoices[0].procs) {
|
||||
raw_printf("No window types?");
|
||||
raw_printf("No window types supported?");
|
||||
nh_terminate(EXIT_FAILURE);
|
||||
}
|
||||
/* 50: arbitrary, no real window_type names are anywhere near that long;
|
||||
used to prevent potential raw_printf() overflow if user supplies a
|
||||
very long string (on the order of 1200 chars) on the command line
|
||||
(config file options can't get that big; they're truncated at 1023) */
|
||||
#define WINDOW_TYPE_MAXLEN 50
|
||||
if (strlen(s) >= WINDOW_TYPE_MAXLEN) {
|
||||
tmps = (char *) alloc(WINDOW_TYPE_MAXLEN);
|
||||
(void) strncpy(tmps, s, WINDOW_TYPE_MAXLEN - 1);
|
||||
tmps[WINDOW_TYPE_MAXLEN - 1] = '\0';
|
||||
s = tmps;
|
||||
}
|
||||
#undef WINDOW_TYPE_MAXLEN
|
||||
|
||||
if (!winchoices[1].procs) {
|
||||
config_error_add(
|
||||
"Window type %s not recognized. The only choice is: %s",
|
||||
@@ -291,6 +305,8 @@ const char *s;
|
||||
config_error_add("Window type %s not recognized. Choices are: %s",
|
||||
s, buf);
|
||||
}
|
||||
if (tmps)
|
||||
free((genericptr_t) tmps) /*, tmps = 0*/ ;
|
||||
|
||||
if (windowprocs.win_raw_print == def_raw_print
|
||||
|| WINDOWPORT("safe-startup"))
|
||||
|
||||
Reference in New Issue
Block a user