public inbox for binutils-cvs@sourceware.org
help / color / mirror / Atom feed
From: Nick Clifton <nickc@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] When gas/read.c calls mbstowcs with a NULL destination, it should set size to 0
Date: Fri,  5 Aug 2022 09:30:23 +0000 (GMT)	[thread overview]
Message-ID: <20220805093023.87FC93858D37@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5858ac626e548772407c038b09b7837550b127dd

commit 5858ac626e548772407c038b09b7837550b127dd
Author: Nick Clifton <nickc@redhat.com>
Date:   Fri Aug 5 10:29:48 2022 +0100

    When gas/read.c calls mbstowcs with a NULL destination, it should set size to 0
    
            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.

Diff:
---
 gas/ChangeLog | 6 ++++++
 gas/read.c    | 5 ++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 5a391a22636..f6b357709b2 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -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
diff --git a/gas/read.c b/gas/read.c
index 800712466be..e23be666dde 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -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))


                 reply	other threads:[~2022-08-05  9:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220805093023.87FC93858D37@sourceware.org \
    --to=nickc@sourceware.org \
    --cc=bfd-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).