Skip to content

Commit 130c5a9

Browse files
committed
feat: allow the large custom NGC packets to be handled also by the client
1 parent d6d67d5 commit 130c5a9

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7dfcf534fb80fbd8337337f5aa9eaa120febc72386046c7ab0d5c7545e900657 /usr/local/bin/tox-bootstrapd
1+
5c4a98ec31bd106717fe81804cd2f2edf04cb51f34ed73ad1513c82dce1f2a04 /usr/local/bin/tox-bootstrapd

toxcore/group_chats.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5117,8 +5117,14 @@ non_null(1, 2, 3, 4) nullable(7)
51175117
static int handle_gc_custom_packet(const GC_Session *c, const GC_Chat *chat, const GC_Peer *peer, const uint8_t *data,
51185118
uint16_t length, bool lossless, void *userdata)
51195119
{
5120-
if (!custom_gc_packet_length_is_valid(length, lossless)) {
5121-
return -1;
5120+
if (lossless) {
5121+
if (length > MAX_GC_CUSTOM_LOSSLESS_INCOMING_ASSEMBLED_PACKET_SIZE) {
5122+
return -1;
5123+
}
5124+
} else {
5125+
if (length > MAX_GC_CUSTOM_LOSSY_PACKET_SIZE) {
5126+
return -1;
5127+
}
51225128
}
51235129

51245130
if (data == nullptr || length == 0) {

toxcore/group_common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
/* Max size of a complete encrypted packet including headers. */
4646
#define MAX_GC_PACKET_SIZE (MAX_GC_PACKET_CHUNK_SIZE * 100)
4747

48+
/* Allow incoming NGC custom packets to be up to the total max size of MAX_GC_PACKET_SIZE.
49+
* The data itself can only be less than that because of NGC header overhead
50+
*/
51+
#define MAX_GC_CUSTOM_LOSSLESS_INCOMING_ASSEMBLED_PACKET_SIZE MAX_GC_PACKET_SIZE
52+
53+
4854
/* Max number of messages to store in the send/recv arrays */
4955
#define GCC_BUFFER_SIZE 8192
5056

0 commit comments

Comments
 (0)