Fix use before assignment
authorFdaSilvaYY <fdasilvayy@gmail.com>
Wed, 16 Nov 2016 21:46:25 +0000 (22:46 +0100)
committerMatt Caswell <matt@openssl.org>
Mon, 23 Jan 2017 14:29:33 +0000 (14:29 +0000)
 it was getting the SerialNumber of a previous cert.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2272)

apps/ca.c

index b48788c6a85457294b847215d6d077064cbd6798..98ec726477d00d63123be0aa706ba841fff79614 100644 (file)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -987,12 +987,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);
 
@@ -1033,8 +1032,8 @@ end_of_options:
                 perror(new_cert);
                 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);
         }