Skip to content

Commit 1b02bad

Browse files
committed
fix possible stack overflow
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.
1 parent f12347d commit 1b02bad

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

toxcore/DHT.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ void dht_get_shared_key_sent(DHT *dht, uint8_t *shared_key, const uint8_t *publi
295295
get_shared_key(dht->mono_time, &dht->shared_keys_sent, shared_key, dht->self_secret_key, public_key);
296296
}
297297

298-
#define CRYPTO_SIZE 1 + CRYPTO_PUBLIC_KEY_SIZE * 2 + CRYPTO_NONCE_SIZE
298+
#define CRYPTO_SIZE (1 + CRYPTO_PUBLIC_KEY_SIZE * 2 + CRYPTO_NONCE_SIZE)
299299

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

0 commit comments

Comments
 (0)