Skip to content

Commit ebc9643

Browse files
committed
fix: don't pass garbage data buffer to packet send functions
This garbage data was never looked at due to passing a zero length along with it, but it's still undesirable.
1 parent 32b68cf commit ebc9643

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d5061af781d04d17bf26174c129b6149e0c8a120ef41133a51a8a7cc5e571e37 /usr/local/bin/tox-bootstrapd
1+
a8e6d6d075090f4e6d27f59dd2e859a152948b3fac7f0b073386172339ec5d8d /usr/local/bin/tox-bootstrapd

toxcore/group_chats.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,16 +2107,17 @@ static int handle_gc_tcp_relays(GC_Chat *chat, GC_Connection *gconn, const uint8
21072107
non_null()
21082108
static bool send_gc_invite_request(const GC_Chat *chat, GC_Connection *gconn)
21092109
{
2110-
uint16_t length = 0;
2110+
if (!chat_is_password_protected(chat)) {
2111+
return send_lossless_group_packet(chat, gconn, nullptr, 0, GP_INVITE_REQUEST);
2112+
}
2113+
21112114
uint8_t data[sizeof(uint16_t) + MAX_GC_PASSWORD_SIZE];
21122115

2113-
if (chat_is_password_protected(chat)) {
2114-
net_pack_u16(data, chat->shared_state.password_length);
2115-
length += sizeof(uint16_t);
2116+
net_pack_u16(data, chat->shared_state.password_length);
2117+
uint16_t length = sizeof(uint16_t);
21162118

2117-
memcpy(data + length, chat->shared_state.password, MAX_GC_PASSWORD_SIZE);
2118-
length += MAX_GC_PASSWORD_SIZE;
2119-
}
2119+
memcpy(data + length, chat->shared_state.password, MAX_GC_PASSWORD_SIZE);
2120+
length += MAX_GC_PASSWORD_SIZE;
21202121

21212122
return send_lossless_group_packet(chat, gconn, data, length, GP_INVITE_REQUEST);
21222123
}

0 commit comments

Comments
 (0)