public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug string/29265] New: mbstowcs with NULL dst throws an incorrect warning (glibc == 2.35, gcc=12.0.1)
@ 2022-06-20 14:01 goldstein.w.n at gmail dot com
  2022-06-21  2:37 ` [Bug string/29265] " siddhesh at sourceware dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: goldstein.w.n at gmail dot com @ 2022-06-20 14:01 UTC (permalink / raw)
  To: glibc-bugs

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-08-06  9:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-20 14:01 [Bug string/29265] New: mbstowcs with NULL dst throws an incorrect warning (glibc == 2.35, gcc=12.0.1) goldstein.w.n at gmail dot com
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

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).