diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2010-02-18 19:06:14 +0300 |
---|---|---|
committer | Cyrill Gorcunov <gorcunov@gmail.com> | 2010-02-18 19:06:14 +0300 |
commit | 7bb0e5263a5c63a6910257804c03ffba11a3044f (patch) | |
tree | 12d7f499e75c8be49d0a29059d90e936329f01a4 | |
parent | 1579c8818588259198f7fa7bf3b7736164d73b60 (diff) | |
download | nasm-7bb0e5263a5c63a6910257804c03ffba11a3044f.tar.gz nasm-7bb0e5263a5c63a6910257804c03ffba11a3044f.tar.bz2 nasm-7bb0e5263a5c63a6910257804c03ffba11a3044f.zip |
labels.c: Fix NULL dereference on too long identifiers
In case if label is local and exceed maximum allowed length
we get NULL dereference. Fix it and warn a user about an accident.
Note that we don't print identifier itself since we know it's too
big. Line number of error is enough.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rw-r--r-- | labels.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -142,8 +142,11 @@ static union label *find_label(char *label, int create) prev = prevlabel; prevlen = strlen(prev); len = strlen(label); - if (prevlen+len >= IDLEN_MAX) + if (prevlen+len >= IDLEN_MAX) { + nasm_error(ERR_NONFATAL, "identifier length exceed %i bytes", + IDLEN_MAX); return NULL; /* Error... */ + } memcpy(label_str, prev, prevlen); memcpy(label_str+prevlen, label, len+1); label = label_str; @@ -292,6 +295,8 @@ void define_label(char *label, int32_t segment, int64_t offset, char *special, label, segment, offset, special, is_norm, isextrn); #endif lptr = find_label(label, 1); + if (!lptr) + return; if (lptr->defn.is_global & DEFINED_BIT) { nasm_error(ERR_NONFATAL, "symbol `%s' redefined", label); return; @@ -351,6 +356,8 @@ void define_common(char *label, int32_t segment, int32_t size, char *special) union label *lptr; lptr = find_label(label, 1); + if (!lptr) + return; if ((lptr->defn.is_global & DEFINED_BIT) && (passn == 1 || !(lptr->defn.is_global & COMMON_BIT))) { nasm_error(ERR_NONFATAL, "symbol `%s' redefined", label); @@ -389,6 +396,8 @@ void declare_as_global(char *label, char *special) return; } lptr = find_label(label, 1); + if (!lptr) + return; switch (lptr->defn.is_global & TYPE_MASK) { case NOT_DEFINED_YET: lptr->defn.is_global = GLOBAL_PLACEHOLDER; |