Skip to content

Commit

Permalink
fix possible stack overflow
Browse files Browse the repository at this point in the history
CRYPTO_SIZE is used in a subtraction as second argument and instead of
subtracting then intended value only '1' is subtracted due to operator
precedence rules and missing braces.
  • Loading branch information
sudden6 committed Dec 5, 2021
1 parent f12347d commit 1b02bad
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion toxcore/DHT.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void dht_get_shared_key_sent(DHT *dht, uint8_t *shared_key, const uint8_t *publi
get_shared_key(dht->mono_time, &dht->shared_keys_sent, shared_key, dht->self_secret_key, public_key);
}

#define CRYPTO_SIZE 1 + CRYPTO_PUBLIC_KEY_SIZE * 2 + CRYPTO_NONCE_SIZE
#define CRYPTO_SIZE (1 + CRYPTO_PUBLIC_KEY_SIZE * 2 + CRYPTO_NONCE_SIZE)

/* Create a request to peer.
* send_public_key and send_secret_key are the pub/secret keys of the sender.
Expand Down

0 comments on commit 1b02bad

Please sign in to comment.