@@ -156,6 +156,11 @@ typedef enum Group_Sync_Flags {
156156 GF_STATE = (1 << 2 ), // 4
157157} Group_Sync_Flags ;
158158
159+ typedef enum Group_CustomPkts_Direction {
160+ GC_CUSTOMPKTS_SENDING = (1 << 0 ), // 1
161+ GC_CUSTOMPKTS_RECEIVING = (1 << 1 ), // 2
162+ } Group_CustomPkts_Direction ;
163+
159164non_null () static bool self_gc_is_founder (const GC_Chat * chat );
160165non_null () static bool group_number_valid (const GC_Session * c , int group_number );
161166non_null () static int peer_update (const GC_Chat * chat , const GC_Peer * peer , uint32_t peer_number );
@@ -4906,11 +4911,17 @@ static int handle_gc_private_message(const GC_Session *c, const GC_Chat *chat, c
49064911}
49074912
49084913/** @brief Returns false if a custom packet is too large. */
4909- static bool custom_gc_packet_length_is_valid (uint16_t length , bool lossless )
4914+ static bool custom_gc_packet_length_is_valid (uint16_t length , bool lossless , Group_CustomPkts_Direction pkt_direction )
49104915{
49114916 if (lossless ) {
4912- if (length > MAX_GC_CUSTOM_LOSSLESS_PACKET_SIZE ) {
4913- return false;
4917+ if (pkt_direction == GC_CUSTOMPKTS_SENDING ) {
4918+ if (length > MAX_GC_CUSTOM_LOSSLESS_PACKET_SIZE ) {
4919+ return false;
4920+ }
4921+ } else {
4922+ if (length > MAX_GC_PACKET_SIZE ) {
4923+ return false;
4924+ }
49144925 }
49154926 } else {
49164927 if (length > MAX_GC_CUSTOM_LOSSY_PACKET_SIZE ) {
@@ -4924,7 +4935,7 @@ static bool custom_gc_packet_length_is_valid(uint16_t length, bool lossless)
49244935int gc_send_custom_private_packet (const GC_Chat * chat , bool lossless , uint32_t peer_id , const uint8_t * message ,
49254936 uint16_t length )
49264937{
4927- if (!custom_gc_packet_length_is_valid (length , lossless )) {
4938+ if (!custom_gc_packet_length_is_valid (length , lossless , GC_CUSTOMPKTS_SENDING )) {
49284939 return -1 ;
49294940 }
49304941
@@ -4966,7 +4977,7 @@ non_null(1, 2, 3, 4) nullable(7)
49664977static int handle_gc_custom_private_packet (const GC_Session * c , const GC_Chat * chat , const GC_Peer * peer ,
49674978 const uint8_t * data , uint16_t length , bool lossless , void * userdata )
49684979{
4969- if (!custom_gc_packet_length_is_valid (length , lossless )) {
4980+ if (!custom_gc_packet_length_is_valid (length , lossless , GC_CUSTOMPKTS_RECEIVING )) {
49704981 return -1 ;
49714982 }
49724983
@@ -4987,7 +4998,7 @@ static int handle_gc_custom_private_packet(const GC_Session *c, const GC_Chat *c
49874998
49884999int gc_send_custom_packet (const GC_Chat * chat , bool lossless , const uint8_t * data , uint16_t length )
49895000{
4990- if (!custom_gc_packet_length_is_valid (length , lossless )) {
5001+ if (!custom_gc_packet_length_is_valid (length , lossless , GC_CUSTOMPKTS_SENDING )) {
49915002 return -1 ;
49925003 }
49935004
@@ -5017,7 +5028,7 @@ non_null(1, 2, 3, 4) nullable(7)
50175028static int handle_gc_custom_packet (const GC_Session * c , const GC_Chat * chat , const GC_Peer * peer , const uint8_t * data ,
50185029 uint16_t length , bool lossless , void * userdata )
50195030{
5020- if (!custom_gc_packet_length_is_valid (length , lossless )) {
5031+ if (!custom_gc_packet_length_is_valid (length , lossless , GC_CUSTOMPKTS_RECEIVING )) {
50215032 return -1 ;
50225033 }
50235034
@@ -6057,6 +6068,7 @@ static bool handle_gc_lossless_packet(const GC_Session *c, GC_Chat *chat, const
60576068 uint8_t packet_type ;
60586069 uint64_t message_id ;
60596070
6071+
60606072 const int len = group_packet_unwrap (chat -> log , gconn , data , & message_id , & packet_type , packet , length );
60616073
60626074 if (len < 0 ) {
0 commit comments