Skip to content

Commit 5fe71fd

Browse files
Dan Carpenterdavem330
authored andcommitted
tipc: re-order conditions in tipc_crypto_key_rcv()
On a 32bit system the "keylen + sizeof(struct tipc_aead_key)" math could have an integer wrapping issue. It doesn't matter because the "keylen" is checked on the next line, but just to make life easier for static analysis tools, let's re-order these conditions and avoid the integer overflow. Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent af10e09 commit 5fe71fd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/tipc/crypto.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2293,8 +2293,8 @@ static bool tipc_crypto_key_rcv(struct tipc_crypto *rx, struct tipc_msg *hdr)
22932293
keylen = ntohl(*((__be32 *)(data + TIPC_AEAD_ALG_NAME)));
22942294

22952295
/* Verify the supplied size values */
2296-
if (unlikely(size != keylen + sizeof(struct tipc_aead_key) ||
2297-
keylen > TIPC_AEAD_KEY_SIZE_MAX)) {
2296+
if (unlikely(keylen > TIPC_AEAD_KEY_SIZE_MAX ||
2297+
size != keylen + sizeof(struct tipc_aead_key))) {
22982298
pr_debug("%s: invalid MSG_CRYPTO key size\n", rx->name);
22992299
goto exit;
23002300
}

0 commit comments

Comments
 (0)