public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "goldstein.w.n at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug string/29265] New: mbstowcs with NULL dst throws an incorrect warning (glibc == 2.35, gcc=12.0.1)
Date: Mon, 20 Jun 2022 14:01:07 +0000	[thread overview]
Message-ID: <bug-29265-131@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=29265

            Bug ID: 29265
           Summary: mbstowcs with NULL dst throws an incorrect warning
                    (glibc == 2.35, gcc=12.0.1)
           Product: glibc
           Version: 2.35
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: string
          Assignee: unassigned at sourceware dot org
          Reporter: goldstein.w.n at gmail dot com
  Target Milestone: ---

For example building binutils HEAD get the following warning:

```
In file included from /usr/include/features.h:486,
                 from
/usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
                 from /usr/include/stdio.h:27,
                 from as.h:42,
                 from read.c:33:
In function ‘mbstowcs’,
    inlined from ‘read_symbol_name’ at read.c:1670:11:
/usr/include/x86_64-linux-gnu/bits/stdlib.h:115:10: error: argument 1 is null
but the corresponding size argument 3 value is [128, 9223372036854775807]
[-Werror=nonnull]
  115 |   return __glibc_fortify_n (mbstowcs, __len, sizeof (wchar_t),
      |          ^~~~~~~~~~~~~~~~~
In file included from /usr/include/stdlib.h:1027,
                 from as.h:44:
/usr/include/x86_64-linux-gnu/bits/stdlib.h: In function ‘read_symbol_name’:
/usr/include/x86_64-linux-gnu/bits/stdlib.h:95:15: note: in a call to function
‘__mbstowcs_chk’ declared with attribute ‘access (read_only, 2)’
   95 | extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,

```

Which is from:
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gas/read.c;h=c6ce0345892284a48e5280ebb9cca111fab975f4;hb=HEAD#l1670
```
1670:    if (mbstowcs (NULL, name, len) == (size_t) -1)
```

`mbstowcs` supports a NULL destination:
https://en.cppreference.com/w/cpp/string/multibyte/mbstowcs#:~:text=POSIX%20specifies%20a%20common%20extension%3A%20if%20dst%20is%20a%20null%20pointer%2C%20this%20function%20returns%20the%20number%20of%20wide%20characters%20that%20would%20be%20written%20to%20dst%2C%20if%20converted.%20Similar%20behavior%20is%20standard%20for%20std%3A%3Ambsrtowcs.

so that seems like a bug in the GLIBC attributes of `mbstowcs`.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2022-06-20 14:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20 14:01 goldstein.w.n at gmail dot com [this message]
2022-06-21  2:37 ` [Bug string/29265] " siddhesh at sourceware dot org
2022-06-21  2:44 ` goldstein.w.n at gmail dot com
2022-06-21  3:30 ` goldstein.w.n at gmail dot com
2022-06-21  3:46 ` siddhesh at sourceware dot org
2022-06-21  4:26 ` goldstein.w.n at gmail dot com
2022-06-21  4:45 ` siddhesh at sourceware dot org
2022-08-06  9:16 ` vincent.vsmeets at gmail dot com

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=bug-29265-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@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).