@@ -380,12 +380,12 @@ int dht_create_packet(const Memory *mem, const Random *rng,
380
380
381
381
const int encrypted_length = encrypt_data_symmetric (shared_key , nonce , plain , plain_length , encrypted );
382
382
383
- if (encrypted_length == -1 ) {
383
+ if (encrypted_length < 0 ) {
384
384
mem_delete (mem , encrypted );
385
385
return -1 ;
386
386
}
387
387
388
- if (length < 1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + encrypted_length ) {
388
+ if (length < 1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + ( size_t ) encrypted_length ) {
389
389
mem_delete (mem , encrypted );
390
390
return -1 ;
391
391
}
@@ -1347,15 +1347,15 @@ static int sendnodes_ipv6(const DHT *dht, const IP_Port *ip_port, const uint8_t
1347
1347
plain [0 ] = num_nodes ;
1348
1348
memcpy (plain + 1 + nodes_length , sendback_data , length );
1349
1349
1350
- const uint32_t crypto_size = 1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + CRYPTO_MAC_SIZE ;
1351
- const uint32_t data_size = 1 + nodes_length + length + crypto_size ;
1350
+ const uint16_t crypto_size = 1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + CRYPTO_MAC_SIZE ;
1351
+ const uint16_t data_size = 1 + nodes_length + length + crypto_size ;
1352
1352
VLA (uint8_t , data , data_size );
1353
1353
1354
1354
const int len = dht_create_packet (dht -> mem , dht -> rng ,
1355
1355
dht -> self_public_key , shared_encryption_key , NET_PACKET_SEND_NODES_IPV6 ,
1356
1356
plain , 1 + nodes_length + length , data , data_size );
1357
1357
1358
- if (len != data_size ) {
1358
+ if (len < 0 || ( uint32_t ) len != data_size ) {
1359
1359
return -1 ;
1360
1360
}
1361
1361
0 commit comments