Re: [PATCH] kunit: Protect string comparisons against NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 20 Dec 2023 at 23:52, Richard Fitzgerald
<rf@xxxxxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxxxx>
> ---

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.

Reviewed-by: David Gow <davidgow@xxxxxxxxxx>

Cheers,
-- David

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux