]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
PMKSA: Guard against NULL KCK for memcpy()
authorBenjamin Berg <benjamin.berg@intel.com>
Fri, 14 Jun 2024 08:13:44 +0000 (10:13 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 11 Jul 2024 16:48:11 +0000 (19:48 +0300)
If the kck_len is 0 then the pointer may be NULL. If that happens UBSAN
complains about the NULL pointer as memcpy() has the arguments declared
to never be NULL even if the copied number of bytes were zero.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
src/rsn_supp/pmksa_cache.c

index f90dcd9b0aeddaba425788600dac410e9d7b5dcf..5bfcbd27e870da4e03c85d95257929e4595d8b2d 100644 (file)
@@ -253,7 +253,8 @@ pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len,
                return NULL;
        os_memcpy(entry->pmk, pmk, pmk_len);
        entry->pmk_len = pmk_len;
-       os_memcpy(entry->kck, kck, kck_len);
+       if (kck_len > 0)
+               os_memcpy(entry->kck, kck, kck_len);
        entry->kck_len = kck_len;
        if (pmkid)
                os_memcpy(entry->pmkid, pmkid, PMKID_LEN);