Skip to content

Commit 9d91a1d

Browse files
Qingling-Wujukkar
authored andcommitted
[noup] zephyr: crypto: fix coverity issue in crypto_ecdh_set_peerkey
Fix INTEGER_OVERFLOW coverity issue. crypto_ecdh_set_peerkey: The decrement operator on the unsigned variable len might result in an underflow. Check value of the unsigned variable len before decrement. Signed-off-by: Qingling Wu <qingling.wu@nxp.com>
1 parent 8412f4b commit 9d91a1d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/crypto/crypto_mbedtls_alt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,6 +1927,8 @@ struct wpabuf *crypto_ecdh_set_peerkey(struct crypto_ecdh *ecdh, int inc_y, cons
19271927
}
19281928
else if (key[0] == 0x02 || key[0] == 0x03)
19291929
{ /* (inc_y == 0) */
1930+
if(len == 0)
1931+
return NULL;
19301932
--len; /*(repurpose len to prime_len)*/
19311933

19321934
/* mbedtls_ecp_point_read_binary() does not currently support

0 commit comments

Comments
 (0)