From 93d41d82963b2cfd0b24c906f5a8daf53281b559 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin (Intel)" Date: Fri, 16 Aug 2019 01:12:54 -0700 Subject: [PATCH] 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 Signed-off-by: H. Peter Anvin (Intel) --- asm/nasm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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)