Skip to content

Commit 80ac793

Browse files
committed
feat: allow the large custom NGC packets to be handled also by the client
1 parent 6370d0f commit 80ac793

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-
9190d56ef3b346bc1632e6d7ee5fe5362be661bff58f2d6d88b5c1d1827394cd /usr/local/bin/tox-bootstrapd
1+
cbc0080745e6606a0267be2e39cf56366010512be7e8167afe0dfad176441c7a /usr/local/bin/tox-bootstrapd

toxcore/group_chats.c

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

51255131
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)