Fixes CERT MEM04-C; CWE-131 in net_crypto.c

This commit is contained in:
Sean Qureshi 2013-08-18 01:31:54 -07:00
parent 17d3878174
commit a03dcbb54e

View File

@ -406,6 +406,8 @@ static int getcryptconnection_id(uint8_t *public_key)
return -1 if realloc fails */ return -1 if realloc fails */
int realloc_cryptoconnection(uint32_t num) int realloc_cryptoconnection(uint32_t num)
{ {
if (num * sizeof(Crypto_Connection) == 0) return -1;
Crypto_Connection *newcrypto_connections = realloc(crypto_connections, num * sizeof(Crypto_Connection)); Crypto_Connection *newcrypto_connections = realloc(crypto_connections, num * sizeof(Crypto_Connection));
if (newcrypto_connections == NULL && num != 0) if (newcrypto_connections == NULL && num != 0)