diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2021-02-26 13:26:37 +0100 |
---|---|---|
committer | Dr. David von Oheimb <dev@ddvo.net> | 2021-02-28 11:46:34 +0100 |
commit | e60e974414a7e637ff2f946dc2aa24c381a32cc2 (patch) | |
tree | 012a89ccdc1caf06bfa96e9179af7b815c6fc3c1 /apps/x509.c | |
parent | 46a11faf3b86ddd2fcc687a0fcfd982e6d201626 (diff) |
apps/x509.c: Fix mem leaks in processing of -next_serial in print loop
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14340)
Diffstat (limited to 'apps/x509.c')
-rw-r--r-- | apps/x509.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/apps/x509.c b/apps/x509.c index 152537f90a..1108ff7ad4 100644 --- a/apps/x509.c +++ b/apps/x509.c @@ -887,16 +887,16 @@ int x509_main(int argc, char **argv) i2a_ASN1_INTEGER(out, X509_get0_serialNumber(x)); BIO_printf(out, "\n"); } else if (i == next_serial) { - ASN1_INTEGER *ser = X509_get_serialNumber(x); - BIGNUM *bnser = ASN1_INTEGER_to_BN(ser, NULL); + ASN1_INTEGER *ser; + BIGNUM *bnser = ASN1_INTEGER_to_BN(X509_get0_serialNumber(x), NULL); if (bnser == NULL) goto end; - if (!BN_add_word(bnser, 1)) - goto end; - ser = BN_to_ASN1_INTEGER(bnser, NULL); - if (ser == NULL) + if (!BN_add_word(bnser, 1) + || (ser = BN_to_ASN1_INTEGER(bnser, NULL)) == NULL) { + BN_free(bnser); goto end; + } BN_free(bnser); i2a_ASN1_INTEGER(out, ser); ASN1_INTEGER_free(ser); @@ -976,9 +976,8 @@ int x509_main(int argc, char **argv) goto end; } BIO_printf(out, "%s Fingerprint=", OBJ_nid2sn(EVP_MD_type(fdig))); - for (j = 0; j < (int)n; j++) { + for (j = 0; j < (int)n; j++) BIO_printf(out, "%02X%c", md[j], (j + 1 == (int)n) ? '\n' : ':'); - } } else if (i == ocspid) { X509_ocspid_print(out, x); } else if (i == ext) { |