@@ -108,17 +108,29 @@ static_assert(GCC_BUFFER_SIZE <= UINT16_MAX,
108108static_assert (MAX_GC_PACKET_CHUNK_SIZE < MAX_GC_PACKET_SIZE ,
109109 "MAX_GC_PACKET_CHUNK_SIZE must be < MAX_GC_PACKET_SIZE" );
110110
111+ static_assert (MAX_GC_PACKET_INCOMING_CHUNK_SIZE < MAX_GC_PACKET_SIZE ,
112+ "MAX_GC_PACKET_INCOMING_CHUNK_SIZE must be < MAX_GC_PACKET_SIZE" );
113+
114+ static_assert (MAX_GC_PACKET_INCOMING_CHUNK_SIZE >= MAX_GC_PACKET_CHUNK_SIZE ,
115+ "MAX_GC_PACKET_INCOMING_CHUNK_SIZE must be >= MAX_GC_PACKET_CHUNK_SIZE" );
116+
111117// size of a lossless handshake packet - lossless packets can't/shouldn't be split up
112118static_assert (MAX_GC_PACKET_CHUNK_SIZE >= 171 ,
113119 "MAX_GC_PACKET_CHUNK_SIZE must be >= 171" );
114120
121+ static_assert (MAX_GC_PACKET_INCOMING_CHUNK_SIZE >= 171 ,
122+ "MAX_GC_PACKET_INCOMING_CHUNK_SIZE must be >= 171" );
123+
115124// group_moderation constants assume this is the max packet size.
116125static_assert (MAX_GC_PACKET_SIZE >= 50000 ,
117126 "MAX_GC_PACKET_SIZE doesn't match constants in group_moderation.h" );
118127
119128static_assert (MAX_GC_PACKET_SIZE <= UINT16_MAX - MAX_GC_PACKET_CHUNK_SIZE ,
120129 "MAX_GC_PACKET_SIZE must be <= UINT16_MAX - MAX_GC_PACKET_CHUNK_SIZE" );
121130
131+ static_assert (MAX_GC_PACKET_SIZE <= UINT16_MAX - MAX_GC_PACKET_INCOMING_CHUNK_SIZE ,
132+ "MAX_GC_PACKET_SIZE must be <= UINT16_MAX - MAX_GC_PACKET_INCOMING_CHUNK_SIZE" );
133+
122134/** Types of broadcast messages. */
123135typedef enum Group_Message_Type {
124136 GC_MESSAGE_TYPE_NORMAL = 0x00 ,
@@ -6255,13 +6267,13 @@ static int handle_gc_tcp_packet(void *object, int id, const uint8_t *packet, uin
62556267
62566268 if (length <= MIN_TCP_PACKET_SIZE ) {
62576269 LOGGER_WARNING (m -> log , "Got tcp packet with invalid length: %u (expected %u to %u)" , length ,
6258- MIN_TCP_PACKET_SIZE , MAX_GC_PACKET_CHUNK_SIZE + MIN_TCP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE );
6270+ MIN_TCP_PACKET_SIZE , MAX_GC_PACKET_INCOMING_CHUNK_SIZE + MIN_TCP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE );
62596271 return -1 ;
62606272 }
62616273
6262- if (length > MAX_GC_PACKET_CHUNK_SIZE + MIN_TCP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE ) {
6274+ if (length > MAX_GC_PACKET_INCOMING_CHUNK_SIZE + MIN_TCP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE ) {
62636275 LOGGER_WARNING (m -> log , "Got tcp packet with invalid length: %u (expected %u to %u)" , length ,
6264- MIN_TCP_PACKET_SIZE , MAX_GC_PACKET_CHUNK_SIZE + MIN_TCP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE );
6276+ MIN_TCP_PACKET_SIZE , MAX_GC_PACKET_INCOMING_CHUNK_SIZE + MIN_TCP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE );
62656277 return -1 ;
62666278 }
62676279
@@ -6336,13 +6348,13 @@ static int handle_gc_tcp_oob_packet(void *object, const uint8_t *public_key, uns
63366348
63376349 if (length <= GC_MIN_HS_PACKET_PAYLOAD_SIZE ) {
63386350 LOGGER_WARNING (m -> log , "Got tcp oob packet with invalid length: %u (expected %u to %u)" , length ,
6339- GC_MIN_HS_PACKET_PAYLOAD_SIZE , MAX_GC_PACKET_CHUNK_SIZE + CRYPTO_MAC_SIZE + CRYPTO_NONCE_SIZE );
6351+ GC_MIN_HS_PACKET_PAYLOAD_SIZE , MAX_GC_PACKET_INCOMING_CHUNK_SIZE + CRYPTO_MAC_SIZE + CRYPTO_NONCE_SIZE );
63406352 return -1 ;
63416353 }
63426354
6343- if (length > MAX_GC_PACKET_CHUNK_SIZE + CRYPTO_MAC_SIZE + CRYPTO_NONCE_SIZE ) {
6355+ if (length > MAX_GC_PACKET_INCOMING_CHUNK_SIZE + CRYPTO_MAC_SIZE + CRYPTO_NONCE_SIZE ) {
63446356 LOGGER_WARNING (m -> log , "Got tcp oob packet with invalid length: %u (expected %u to %u)" , length ,
6345- GC_MIN_HS_PACKET_PAYLOAD_SIZE , MAX_GC_PACKET_CHUNK_SIZE + CRYPTO_MAC_SIZE + CRYPTO_NONCE_SIZE );
6357+ GC_MIN_HS_PACKET_PAYLOAD_SIZE , MAX_GC_PACKET_INCOMING_CHUNK_SIZE + CRYPTO_MAC_SIZE + CRYPTO_NONCE_SIZE );
63466358 return -1 ;
63476359 }
63486360
@@ -6392,13 +6404,13 @@ static int handle_gc_udp_packet(void *object, const IP_Port *ipp, const uint8_t
63926404
63936405 if (length <= MIN_UDP_PACKET_SIZE ) {
63946406 LOGGER_WARNING (m -> log , "Got UDP packet with invalid length: %u (expected %u to %u)" , length ,
6395- MIN_UDP_PACKET_SIZE , MAX_GC_PACKET_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE );
6407+ MIN_UDP_PACKET_SIZE , MAX_GC_PACKET_INCOMING_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE );
63966408 return -1 ;
63976409 }
63986410
6399- if (length > MAX_GC_PACKET_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE ) {
6411+ if (length > MAX_GC_PACKET_INCOMING_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE ) {
64006412 LOGGER_WARNING (m -> log , "Got UDP packet with invalid length: %u (expected %u to %u)" , length ,
6401- MIN_UDP_PACKET_SIZE , MAX_GC_PACKET_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE );
6413+ MIN_UDP_PACKET_SIZE , MAX_GC_PACKET_INCOMING_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE );
64026414 return -1 ;
64036415 }
64046416
0 commit comments