From: Szabolcs Nagy <szabolcs.nagy@arm.com>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Florian Weimer <fweimer@redhat.com>,
"H.J. Lu" <hjl.tools@gmail.com>,
Noah Goldstein <goldstein.w.n@gmail.com>,
libc-alpha@sourceware.org
Subject: Re: [PATCH v2] string: Fix OOB read on generic strncmp
Date: Fri, 24 Feb 2023 10:19:15 +0000 [thread overview]
Message-ID: <Y/iPI784YA0wMt3t@arm.com> (raw)
In-Reply-To: <ef6c9254-0815-4143-99fb-8b63845fb7fe@linaro.org>
The 02/23/2023 15:15, Adhemerval Zanella Netto wrote:
> Noah has brought to my attention that he tried to add similar tests,
> but they were rejected by strncmp string must be null-terminated [1].
>
> The working drafts for C standard I have access (n1256.pdf for C99 and
> n3047.pdf for c2x) do not say possibly null-terminated array (as some
> stackoverflow answer state [2]) they refer only as array. So I tend
> to follow Florian understanding that strncmp inputs should be NULL
> terminated.
c11 draft is n1570.pdf
https://open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
i dont understand what extension Florian is talking about.
(i think that was about strcmp not strncmp)
c11 and c23 are clear that strncmp args may *not* be null-terminated
so i think we should be careful not to overread.
glibc itself has test code that relies on this: crypt/badsalttest
>
> So should we really consider this a OOB read on generic strncmp?
>
> [1] https://sourceware.org/pipermail/libc-alpha/2022-January/135130.html
> [2] https://stackoverflow.com/questions/41418766/is-it-legal-to-pass-a-non-null-terminated-string-to-strncmp-in-c
next prev parent reply other threads:[~2023-02-24 10:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-22 16:31 Adhemerval Zanella
2023-02-22 17:21 ` Szabolcs Nagy
2023-02-23 18:15 ` Adhemerval Zanella Netto
2023-02-24 10:19 ` Szabolcs Nagy [this message]
2023-02-24 10:58 ` Florian Weimer
2023-02-23 19:10 Wilco Dijkstra
2023-02-24 12:24 Wilco Dijkstra
2023-02-24 12:34 ` Adhemerval Zanella Netto
2023-02-24 12:43 ` Szabolcs Nagy
2023-02-24 12:57 ` Adhemerval Zanella Netto
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=Y/iPI784YA0wMt3t@arm.com \
--to=szabolcs.nagy@arm.com \
--cc=adhemerval.zanella@linaro.org \
--cc=fweimer@redhat.com \
--cc=goldstein.w.n@gmail.com \
--cc=hjl.tools@gmail.com \
--cc=libc-alpha@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).