aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2019-08-16 01:12:54 -0700
committerH. Peter Anvin (Intel) <hpa@zytor.com>2019-08-16 01:12:54 -0700
commit93d41d82963b2cfd0b24c906f5a8daf53281b559 (patch)
tree20413d6a9c3b23bee02519ec71a818908b0fa19b
parent480d5e2c8bb8b0678d23d0e2af51202dbb5cb589 (diff)
downloadnasm-93d41d82963b2cfd0b24c906f5a8daf53281b559.tar.gz
nasm-93d41d82963b2cfd0b24c906f5a8daf53281b559.tar.xz
nasm-93d41d82963b2cfd0b24c906f5a8daf53281b559.zip
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>
-rw-r--r--asm/nasm.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/asm/nasm.c b/asm/nasm.c
index c84d6750..65116ab3 100644
--- a/asm/nasm.c
+++ b/asm/nasm.c
@@ -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)