From: FdaSilvaYY Date: Wed, 16 Nov 2016 21:46:25 +0000 (+0100) Subject: Fix use before assignment X-Git-Tag: OpenSSL_1_1_0d~24 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=45789c2819e1cb93150061ddaa95fe97da2c0cba;p=oweals%2Fopenssl.git Fix use before assignment it was getting the SerialNumber of a previous cert. Reviewed-by: Rich Salz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/2272) (cherry picked from commit 0db1fb3fc13c4b1a2b916efbb374f40579b1398f) --- diff --git a/apps/ca.c b/apps/ca.c index af7bb72e69..1fb7b08f87 100644 --- a/apps/ca.c +++ b/apps/ca.c @@ -983,12 +983,11 @@ end_of_options: BIO_printf(bio_err, "writing new certificates\n"); for (i = 0; i < sk_X509_num(cert_sk); i++) { BIO *Cout = NULL; - ASN1_INTEGER *serialNumber = X509_get_serialNumber(x); + X509 *xi = sk_X509_value(cert_sk, i); + ASN1_INTEGER *serialNumber = X509_get_serialNumber(xi); int k; char *n; - x = sk_X509_value(cert_sk, i); - j = ASN1_STRING_length(serialNumber); p = (const char *)ASN1_STRING_get0_data(serialNumber); @@ -1030,8 +1029,8 @@ end_of_options: perror(buf[2]); goto end; } - write_new_certificate(Cout, x, 0, notext); - write_new_certificate(Sout, x, output_der, notext); + write_new_certificate(Cout, xi, 0, notext); + write_new_certificate(Sout, xi, output_der, notext); BIO_free_all(Cout); }