[ccan] [PATCH 4/7] crypto/hmac_sha256: Remove undefined memset()

Rusty Russell rusty at rustcorp.com.au
Thu Apr 13 09:56:13 AEST 2017


David Gibson <david at gibson.dropbear.id.au> writes:
> [ Unknown signature status ]
> On Tue, Apr 04, 2017 at 11:52:39AM +0930, Paul 'Rusty' Russell wrote:
>> David Gibson <david at gibson.dropbear.id.au> writes:
>> > A memset() with a zero length argument isn't well defined.  It *might* be
>> > a no-op, but then it might not.  So, test for this case in
>> > hmac_sha256_init().
>> 
>> Huh?  That seems really odd.
>
> Well.. more precisely, my understanding is that memset(p, x, 0) can't
> be counted on not to dereference p.

That seems nonsensical, though.

> In this case, k_ipad + ksize is past the end of the array, and so not
> a valid pointer to dereference.

The pointer is valid (C's famous one-past-end exception), dereferencing
it is not.

What's the actual coverity error?

Thanks,
Rusty.


More information about the ccan mailing list