BR 3392576: don't segfault on a bad %pragma limit

Don't segfault on a bad %pragma limit. Instead treat a NULL pointer as
an empty string.

Reported-by: Ren Kimura <rkx1209dev@gmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin (Intel) 2019-08-16 01:12:54 -07:00
parent 480d5e2c8b
commit 93d41d8296

View File

@ -212,6 +212,11 @@ nasm_set_limit(const char *limit, const char *valstr)
bool rn_error;
int errlevel;
if (!limit)
limit = "";
if (!valstr)
valstr = "";
for (i = 0; i <= LIMIT_MAX; i++) {
if (!nasm_stricmp(limit, limit_info[i].name))
break;
@ -234,7 +239,7 @@ nasm_set_limit(const char *limit, const char *valstr)
errlevel = ERR_WARNING|WARN_OTHER|ERR_USAGE;
else
errlevel = ERR_WARNING|WARN_PRAGMA_BAD;
nasm_error(errlevel, "invalid limit value: `%s'", limit);
nasm_error(errlevel, "invalid limit value: `%s'", valstr);
return DIRR_ERROR;
}
if (val > LIMIT_MAX_VAL)