From: "Cédric Le Goater" <clg@redhat.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org,
"Richard Henderson" <richard.henderson@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Markus Armbruster" <armbru@redhat.com>
Subject: Re: [PATCH] log: Fix result of strstr to 'const char *'
Date: Tue, 9 Dec 2025 16:22:28 +0100 [thread overview]
Message-ID: <3045e225-07b5-4a97-b56a-24e34211db7a@redhat.com> (raw)
In-Reply-To: <aTg-X4fIEr43XI9u@redhat.com>
On 12/9/25 16:21, Daniel P. Berrangé wrote:
> On Tue, Dec 09, 2025 at 03:07:04PM +0000, Peter Maydell wrote:
>> On Tue, 9 Dec 2025 at 15:04, Cédric Le Goater <clg@redhat.com> wrote:
>>>
>>> Assigning the result of strstr() to a 'char *' is unsafe since
>>> strstr() returns a pointer into the original string which is a
>>> read-only 'const char *' string. Newer compilers
>>
>> Which ones? Or does this depend on how the libc headers have
>> marked up the strstr() prototype?
>
> I don't believe it is compiler related, rather this is an
> ehancement in glibc 2.42.9000 / git master
>
> https://sourceware.org/git/?p=glibc.git;a=commit;h=cd748a63ab1a7ae846175c532a3daab341c62690
>
> AFAICT it should work with any gcc we have
>
> Although the commit talks about C23, we get it regardless as we have
> _GNU_SOURCE defined.
yes. glibc 2.42.9000 has :
+# if __GLIBC_USE (ISOC23) && defined __glibc_const_generic && !defined _LIBC
+# define strstr(HAYSTACK, NEEDLE) \
+ __glibc_const_generic (HAYSTACK, const char *, \
+ strstr (HAYSTACK, NEEDLE))
+# endif
C.
next prev parent reply other threads:[~2025-12-09 15:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-09 15:03 [PATCH] log: Fix result of strstr to 'const char *' Cédric Le Goater
2025-12-09 15:07 ` Peter Maydell
2025-12-09 15:14 ` Cédric Le Goater
2025-12-09 15:21 ` Daniel P. Berrangé
2025-12-09 15:22 ` Cédric Le Goater [this message]
2025-12-09 15:10 ` Laurent Vivier
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=3045e225-07b5-4a97-b56a-24e34211db7a@redhat.com \
--to=clg@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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 NNTP newsgroup(s).