Skip to content

Commit 7a4cc10

Browse files
committed
fix: Fix a stack overflow triggered by small DHT packets.
This isn't in production yet. It's in the new announce store code. The problem was that a negative plain_len was converted to unsigned, which made it a very large number.
1 parent 2c06ef6 commit 7a4cc10

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
139fe825b90c022bbefd3837c2a427ab9215be3ca62144ea7ff12ae7389c78ba /usr/local/bin/tox-bootstrapd
1+
37e68ca853cd8b01b26c8d8c61d1db6546c08ed294f5650b691b7aadaf47ee18 /usr/local/bin/tox-bootstrapd

toxcore/DHT.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ static int handle_data_search_response(void *object, const IP_Port *source,
10791079

10801080
const int32_t plain_len = (int32_t)length - (1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + CRYPTO_MAC_SIZE);
10811081

1082-
if (plain_len < CRYPTO_PUBLIC_KEY_SIZE + sizeof(uint64_t)) {
1082+
if (plain_len < (int32_t)(CRYPTO_PUBLIC_KEY_SIZE + sizeof(uint64_t))) {
10831083
return 1;
10841084
}
10851085

toxcore/announce.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ static int create_reply(Announcements *announce, const IP_Port *source,
544544
{
545545
const int plain_len = (int)length - (1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + CRYPTO_MAC_SIZE);
546546

547-
if (plain_len < sizeof(uint64_t)) {
547+
if (plain_len < (int)sizeof(uint64_t)) {
548548
return -1;
549549
}
550550

0 commit comments

Comments
 (0)