[nasm:nasm-2.15.xx] BR 3392696: nasm_quote -- fixup callers

nasm-bot for Cyrill Gorcunov gorcunov at gmail.com
Sun Jul 12 06:03:04 PDT 2020


Commit-ID:  65c6ba87166e3dd1143cc399ef535aa86145a450
Gitweb:     http://repo.or.cz/w/nasm.git?a=commitdiff;h=65c6ba87166e3dd1143cc399ef535aa86145a450
Author:     Cyrill Gorcunov <gorcunov at gmail.com>
AuthorDate: Sat, 11 Jul 2020 19:12:13 +0300
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Sun, 12 Jul 2020 06:00:51 -0700

BR 3392696: nasm_quote -- fixup callers

In 41e9682efed7cd1df133b1b4ac806e07723f1486 we've
changed the nasm_quote arguments still not all callers
were converted which could lead to nil dereference.

[hpa: no need to call strlen() for the asm/preproc.c chunk]

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
Signed-off-by: H. Peter Anvin <hpa at zytor.com>


---
 asm/nasm.c    | 4 +++-
 asm/preproc.c | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/asm/nasm.c b/asm/nasm.c
index c5d9aff1..a0e17193 100644
--- a/asm/nasm.c
+++ b/asm/nasm.c
@@ -455,6 +455,7 @@ static char *nasm_quote_filename(const char *fn)
 {
     const unsigned char *p =
         (const unsigned char *)fn;
+    size_t len;
 
     if (!p || !*p)
         return nasm_strdup("\"\"");
@@ -478,7 +479,8 @@ static char *nasm_quote_filename(const char *fn)
     return nasm_strdup(fn);
 
 quote:
-    return nasm_quote(fn, NULL);
+    len = strlen(fn);
+    return nasm_quote(fn, &len);
 }
 
 static void timestamp(void)
diff --git a/asm/preproc.c b/asm/preproc.c
index 8230f16f..8415d572 100644
--- a/asm/preproc.c
+++ b/asm/preproc.c
@@ -796,7 +796,7 @@ Token *quote_token(Token *t)
  */
 static Token *quote_any_token(Token *t)
 {
-    size_t len;
+    size_t len = t->len;
     char *p;
 
     p = nasm_quote(tok_text(t), &len);


More information about the Nasm-commits mailing list