apps: check OPENSSL_uni2utf8 return value

Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29590)
This commit is contained in:
Nikola Pajkovsky
2026-01-09 16:30:10 +01:00
committed by Norbert Pocs
parent 2bc0ee0400
commit 7e535fe6b1

View File

@@ -904,6 +904,12 @@ int pkcs12_main(int argc, char **argv)
if (utmp == NULL) if (utmp == NULL)
goto end; goto end;
badpass = OPENSSL_uni2utf8(utmp, utmplen); badpass = OPENSSL_uni2utf8(utmp, utmplen);
if (badpass == NULL) {
BIO_printf(bio_err, "Verbatim password did not match, and fallback conversion to UTF-8 failed\n"
"The password entered or the input encoding may be wrong\n");
OPENSSL_free(utmp);
goto end;
}
OPENSSL_free(utmp); OPENSSL_free(utmp);
if (!PKCS12_verify_mac(p12, badpass, -1)) { if (!PKCS12_verify_mac(p12, badpass, -1)) {
BIO_printf(bio_err, "Mac verify error: invalid password?\n"); BIO_printf(bio_err, "Mac verify error: invalid password?\n");