Skip to content

Commit

Permalink
tipc: re-order conditions in tipc_crypto_key_rcv()
Browse files Browse the repository at this point in the history
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 <dan.carpenter@linaro.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Dan Carpenter authored and David S. Miller committed Jan 20, 2025
1 parent af10e09 commit 5fe71fd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/tipc/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -2293,8 +2293,8 @@ static bool tipc_crypto_key_rcv(struct tipc_crypto *rx, struct tipc_msg *hdr)
keylen = ntohl(*((__be32 *)(data + TIPC_AEAD_ALG_NAME)));

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

0 comments on commit 5fe71fd

Please sign in to comment.