mirror of
https://github.com/openssl/openssl.git
synced 2025-01-30 14:01:55 +08:00
various kdfs: Always reset buflen after clearing the buffer
Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17165)
This commit is contained in:
parent
29a27cb2c5
commit
d2217c88df
@ -98,6 +98,7 @@ static int krb5kdf_set_membuf(unsigned char **dst, size_t *dst_len,
|
||||
{
|
||||
OPENSSL_clear_free(*dst, *dst_len);
|
||||
*dst = NULL;
|
||||
*dst_len = 0;
|
||||
return OSSL_PARAM_get_octet_string(p, (void **)dst, 0, dst_len);
|
||||
}
|
||||
|
||||
|
@ -134,13 +134,15 @@ static int kdf_pbkdf1_set_membuf(unsigned char **buffer, size_t *buflen,
|
||||
const OSSL_PARAM *p)
|
||||
{
|
||||
OPENSSL_clear_free(*buffer, *buflen);
|
||||
*buffer = NULL;
|
||||
*buflen = 0;
|
||||
|
||||
if (p->data_size == 0) {
|
||||
if ((*buffer = OPENSSL_malloc(1)) == NULL) {
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
} else if (p->data != NULL) {
|
||||
*buffer = NULL;
|
||||
if (!OSSL_PARAM_get_octet_string(p, (void **)buffer, 0, buflen))
|
||||
return 0;
|
||||
}
|
||||
|
@ -126,13 +126,15 @@ static int pbkdf2_set_membuf(unsigned char **buffer, size_t *buflen,
|
||||
const OSSL_PARAM *p)
|
||||
{
|
||||
OPENSSL_clear_free(*buffer, *buflen);
|
||||
*buffer = NULL;
|
||||
*buflen = 0;
|
||||
|
||||
if (p->data_size == 0) {
|
||||
if ((*buffer = OPENSSL_malloc(1)) == NULL) {
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
} else if (p->data != NULL) {
|
||||
*buffer = NULL;
|
||||
if (!OSSL_PARAM_get_octet_string(p, (void **)buffer, 0, buflen))
|
||||
return 0;
|
||||
}
|
||||
|
@ -182,13 +182,15 @@ static int pkcs12kdf_set_membuf(unsigned char **buffer, size_t *buflen,
|
||||
const OSSL_PARAM *p)
|
||||
{
|
||||
OPENSSL_clear_free(*buffer, *buflen);
|
||||
*buffer = NULL;
|
||||
*buflen = 0;
|
||||
|
||||
if (p->data_size == 0) {
|
||||
if ((*buffer = OPENSSL_malloc(1)) == NULL) {
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
} else if (p->data != NULL) {
|
||||
*buffer = NULL;
|
||||
if (!OSSL_PARAM_get_octet_string(p, (void **)buffer, 0, buflen))
|
||||
return 0;
|
||||
}
|
||||
|
@ -108,13 +108,15 @@ static int scrypt_set_membuf(unsigned char **buffer, size_t *buflen,
|
||||
const OSSL_PARAM *p)
|
||||
{
|
||||
OPENSSL_clear_free(*buffer, *buflen);
|
||||
*buffer = NULL;
|
||||
*buflen = 0;
|
||||
|
||||
if (p->data_size == 0) {
|
||||
if ((*buffer = OPENSSL_malloc(1)) == NULL) {
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
} else if (p->data != NULL) {
|
||||
*buffer = NULL;
|
||||
if (!OSSL_PARAM_get_octet_string(p, (void **)buffer, 0, buflen))
|
||||
return 0;
|
||||
}
|
||||
|
@ -91,6 +91,7 @@ static int sshkdf_set_membuf(unsigned char **dst, size_t *dst_len,
|
||||
{
|
||||
OPENSSL_clear_free(*dst, *dst_len);
|
||||
*dst = NULL;
|
||||
*dst_len = 0;
|
||||
return OSSL_PARAM_get_octet_string(p, (void **)dst, 0, dst_len);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user