]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
When gas/read.c calls mbstowcs with a NULL destination, it should set size to 0
authorNick Clifton <nickc@redhat.com>
Fri, 5 Aug 2022 09:29:48 +0000 (10:29 +0100)
committerNick Clifton <nickc@redhat.com>
Fri, 5 Aug 2022 09:29:48 +0000 (10:29 +0100)
PR 29447
* read.c (read_symbol_name): Pass 0 as the length parameter when
invoking mbstowc in order to check the validity of a wide string.

gas/ChangeLog
gas/read.c

index 5a391a226366b895cceb51d71f2e941547e246d6..f6b357709b2106f3ace5bfd30ad8bec51271af32 100644 (file)
@@ -1,3 +1,9 @@
+2022-08-05  Nick Clifton  <nickc@redhat.com>
+
+       PR 29447
+       * read.c (read_symbol_name): Pass 0 as the length parameter when
+       invoking mbstowc in order to check the validity of a wide string.
+
 2022-07-18  Claudiu Zissulescu  <claziss@synopsys.com>
 
        * config/tc-arc.c (md_assembly): Update strspn string with the
index 800712466be06f223a053360eb7ddb75c57842ab..e23be666dde4ce3b80d71c367935a300ad68896d 100644 (file)
@@ -1629,7 +1629,10 @@ read_symbol_name (void)
       /* Since quoted symbol names can contain non-ASCII characters,
         check the string and warn if it cannot be recognised by the
         current character set.  */
-      if (mbstowcs (NULL, name, len) == (size_t) -1)
+      /* PR 29447: mbstowcs ignores the third (length) parameter when
+        the first (destination) parameter is NULL.  For clarity sake
+        therefore we pass 0 rather than 'len' as the third parameter.  */
+      if (mbstowcs (NULL, name, 0) == (size_t) -1)
        as_warn (_("symbol name not recognised in the current locale"));
     }
   else if (is_name_beginner (c) || (input_from_string && c == FAKE_LABEL_CHAR))