From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: David Gow <davidgow@google.com>
Cc: <brendan.higgins@linux.dev>, <rmoar@google.com>,
<linux-kselftest@vger.kernel.org>, <kunit-dev@googlegroups.com>,
<linux-kernel@vger.kernel.org>, <patches@opensource.cirrus.com>
Subject: Re: [PATCH] kunit: Protect string comparisons against NULL
Date: Thu, 4 Jan 2024 11:52:28 +0000 [thread overview]
Message-ID: <c6a4c016-e889-422c-91aa-91568f6667f4@opensource.cirrus.com> (raw)
In-Reply-To: <CABVgOSnoJEZOCdPBVqBKS=sEXeeq_6_+G4PPodY0HWJ3A7yA+A@mail.gmail.com>
On 22/12/23 08:39, David Gow wrote:
> On Wed, 20 Dec 2023 at 23:52, Richard Fitzgerald
> <rf@opensource.cirrus.com> wrote:
>>
>> Add NULL checks to KUNIT_BINARY_STR_ASSERTION() so that it will fail
>> cleanly if either pointer is NULL, instead of causing a NULL pointer
>> dereference in the strcmp().
>>
>> A test failure could be that a string is unexpectedly NULL. This could
>> be trapped by KUNIT_ASSERT_NOT_NULL() but that would terminate the test
>> at that point. It's preferable that the KUNIT_EXPECT_STR*() macros can
>> handle NULL pointers as a failure.
>>
>> Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
>> ---
>
> I think this is the right thing to do. There's possibly an argument
> that this should succeed if both are NULL, but I prefer it this way.
>
Maybe an _OR_NULL() variant of the string test macros would be better to
be explicit that NULL is acceptable.
> Reviewed-by: David Gow <davidgow@google.com>
>
> Cheers,
> -- David
next prev parent reply other threads:[~2024-01-04 11:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-20 15:52 [PATCH] kunit: Protect string comparisons against NULL Richard Fitzgerald
2023-12-22 8:39 ` David Gow
2024-01-04 11:52 ` Richard Fitzgerald [this message]
2023-12-30 7:17 ` Muhammad Usama Anjum
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=c6a4c016-e889-422c-91aa-91568f6667f4@opensource.cirrus.com \
--to=rf@opensource.cirrus.com \
--cc=brendan.higgins@linux.dev \
--cc=davidgow@google.com \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=rmoar@google.com \
/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