mirror of
https://github.com/openssl/openssl.git
synced 2025-03-25 20:00:44 +08:00
Fix potential NULL dereference in OSSL_PARAM_get_utf8_string()
Fixes Coverity ID 1476283 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14928)
This commit is contained in:
parent
db6b1266ab
commit
1fac270501
@ -1128,11 +1128,13 @@ int OSSL_PARAM_get_utf8_string(const OSSL_PARAM *p, char **val, size_t max_len)
|
||||
*/
|
||||
size_t data_length = p->data_size;
|
||||
|
||||
if (ret == 0)
|
||||
return 0;
|
||||
if (data_length >= max_len)
|
||||
data_length = OPENSSL_strnlen(p->data, data_length);
|
||||
if (data_length >= max_len)
|
||||
return 0; /* No space for a terminating NUL byte */
|
||||
((char *)*val)[data_length] = '\0';
|
||||
(*val)[data_length] = '\0';
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -566,7 +566,7 @@ static int do_check_utf8_str(OSSL_PARAM params[], const char *key,
|
||||
const char *expected)
|
||||
{
|
||||
OSSL_PARAM *p;
|
||||
char *bufp = 0;
|
||||
char *bufp = NULL;
|
||||
int ret;
|
||||
|
||||
ret = TEST_ptr(p = OSSL_PARAM_locate(params, key))
|
||||
|
Loading…
x
Reference in New Issue
Block a user