Skip to content

Commit 7b05833

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

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

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)