If RAND_bytes fails, then we will attempt to double-free crypt->key.data.
From Andrew Bartlett. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17518 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -1443,6 +1443,7 @@ hx509_crypto_set_key_data(hx509_crypto crypto, const void *data, size_t length)
|
|||||||
|
|
||||||
if (crypto->key.data) {
|
if (crypto->key.data) {
|
||||||
free(crypto->key.data);
|
free(crypto->key.data);
|
||||||
|
crypto->key.data = NULL;
|
||||||
crypto->key.length = 0;
|
crypto->key.length = 0;
|
||||||
}
|
}
|
||||||
crypto->key.data = malloc(length);
|
crypto->key.data = malloc(length);
|
||||||
@@ -1470,6 +1471,7 @@ hx509_crypto_set_random_key(hx509_crypto crypto, heim_octet_string *key)
|
|||||||
}
|
}
|
||||||
if (RAND_bytes(crypto->key.data, crypto->key.length) <= 0) {
|
if (RAND_bytes(crypto->key.data, crypto->key.length) <= 0) {
|
||||||
free(crypto->key.data);
|
free(crypto->key.data);
|
||||||
|
crypto->key.data = NULL;
|
||||||
crypto->key.length = 0;
|
crypto->key.length = 0;
|
||||||
return HX509_CRYPTO_INTERNAL_ERROR;
|
return HX509_CRYPTO_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user