apps/spkac.c: Check result of ASN1_STRING_set()

Fixes Coverity 1027256

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21755)
This commit is contained in:
Tomas Mraz 2023-08-16 15:58:33 +02:00
parent 79cdbe893d
commit 20baa24f9f
1 changed files with 4 additions and 3 deletions

View File

@ -152,9 +152,10 @@ int spkac_main(int argc, char **argv)
spki = NETSCAPE_SPKI_new();
if (spki == NULL)
goto end;
if (challenge != NULL)
ASN1_STRING_set(spki->spkac->challenge,
challenge, (int)strlen(challenge));
if (challenge != NULL
&& !ASN1_STRING_set(spki->spkac->challenge,
challenge, (int)strlen(challenge)))
goto end;
if (!NETSCAPE_SPKI_set_pubkey(spki, pkey)) {
BIO_printf(bio_err, "Error setting public key\n");
goto end;