From 327a720d5dd011b853acbdd0223933f6ecd22928 Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Mon, 28 Mar 2022 19:13:22 +0200 Subject: OSSL_PARAM_get_*_ptr: Drop errors from ptr/string mismatch Reviewed-by: Dmitry Belyavskiy Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/17997) --- crypto/params.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'crypto') diff --git a/crypto/params.c b/crypto/params.c index a1a04a6b4d..321b919ccc 100644 --- a/crypto/params.c +++ b/crypto/params.c @@ -1506,14 +1506,25 @@ static int get_string_ptr_internal(const OSSL_PARAM *p, const void **val, int OSSL_PARAM_get_utf8_string_ptr(const OSSL_PARAM *p, const char **val) { - return OSSL_PARAM_get_utf8_ptr(p, val) - || get_string_ptr_internal(p, (const void **)val, NULL, - OSSL_PARAM_UTF8_STRING); + int rv; + + ERR_set_mark(); + rv = OSSL_PARAM_get_utf8_ptr(p, val); + ERR_pop_to_mark(); + + return rv || get_string_ptr_internal(p, (const void **)val, NULL, + OSSL_PARAM_UTF8_STRING); } int OSSL_PARAM_get_octet_string_ptr(const OSSL_PARAM *p, const void **val, size_t *used_len) { - return OSSL_PARAM_get_octet_ptr(p, val, used_len) - || get_string_ptr_internal(p, val, used_len, OSSL_PARAM_OCTET_STRING); + int rv; + + ERR_set_mark(); + rv = OSSL_PARAM_get_octet_ptr(p, val, used_len); + ERR_pop_to_mark(); + + return rv || get_string_ptr_internal(p, val, used_len, + OSSL_PARAM_OCTET_STRING); } -- cgit v1.2.3