@@ -1223,7 +1223,8 @@ static bool file_sendrequest(const Messenger *m, int32_t friendnumber, uint8_t f
12231223 return false;
12241224 }
12251225
1226- VLA (uint8_t , packet , 1 + sizeof (file_type ) + sizeof (filesize ) + FILE_ID_LENGTH + filename_length );
1226+ const uint16_t packet_size = 1 + sizeof (file_type ) + sizeof (filesize ) + FILE_ID_LENGTH + filename_length ;
1227+ VLA (uint8_t , packet , packet_size );
12271228 packet [0 ] = filenumber ;
12281229 file_type = net_htonl (file_type );
12291230 memcpy (packet + 1 , & file_type , sizeof (file_type ));
@@ -1234,7 +1235,7 @@ static bool file_sendrequest(const Messenger *m, int32_t friendnumber, uint8_t f
12341235 memcpy (packet + 1 + sizeof (file_type ) + sizeof (filesize ) + FILE_ID_LENGTH , filename , filename_length );
12351236 }
12361237
1237- return write_cryptpacket_id (m , friendnumber , PACKET_ID_FILE_SENDREQUEST , packet , SIZEOF_VLA ( packet ) , false);
1238+ return write_cryptpacket_id (m , friendnumber , PACKET_ID_FILE_SENDREQUEST , packet , packet_size , false);
12381239}
12391240
12401241/** @brief Send a file send request.
@@ -1301,7 +1302,8 @@ static bool send_file_control_packet(const Messenger *m, int32_t friendnumber, b
13011302 return false;
13021303 }
13031304
1304- VLA (uint8_t , packet , 3 + data_length );
1305+ const uint16_t packet_size = 3 + data_length ;
1306+ VLA (uint8_t , packet , packet_size );
13051307
13061308 packet [0 ] = inbound ? 1 : 0 ;
13071309 packet [1 ] = filenumber ;
@@ -1311,7 +1313,7 @@ static bool send_file_control_packet(const Messenger *m, int32_t friendnumber, b
13111313 memcpy (packet + 3 , data , data_length );
13121314 }
13131315
1314- return write_cryptpacket_id (m , friendnumber , PACKET_ID_FILE_CONTROL , packet , SIZEOF_VLA ( packet ) , false);
1316+ return write_cryptpacket_id (m , friendnumber , PACKET_ID_FILE_CONTROL , packet , packet_size , false);
13151317}
13161318
13171319/** @brief Send a file control request.
@@ -1501,7 +1503,8 @@ static int64_t send_file_data_packet(const Messenger *m, int32_t friendnumber, u
15011503 return -1 ;
15021504 }
15031505
1504- VLA (uint8_t , packet , 2 + length );
1506+ const uint16_t packet_size = 2 + length ;
1507+ VLA (uint8_t , packet , packet_size );
15051508 packet [0 ] = PACKET_ID_FILE_DATA ;
15061509 packet [1 ] = filenumber ;
15071510
@@ -1510,7 +1513,7 @@ static int64_t send_file_data_packet(const Messenger *m, int32_t friendnumber, u
15101513 }
15111514
15121515 return write_cryptpacket (m -> net_crypto , friend_connection_crypt_connection_id (m -> fr_c ,
1513- m -> friendlist [friendnumber ].friendcon_id ), packet , SIZEOF_VLA ( packet ) , true);
1516+ m -> friendlist [friendnumber ].friendcon_id ), packet , packet_size , true);
15141517}
15151518
15161519#define MAX_FILE_DATA_SIZE (MAX_CRYPTO_DATA_SIZE - 2)
0 commit comments