apps/ca: fix useless get before delete.
authorFdaSilvaYY <fdasilvayy@gmail.com>
Tue, 8 May 2018 07:47:26 +0000 (09:47 +0200)
committerAndy Polyakov <appro@openssl.org>
Thu, 21 Jun 2018 13:14:06 +0000 (15:14 +0200)
Small simplification by skipping effectively redundant step and
not resuming search from point past deletion.

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6195)

apps/ca.c

index 4a8396ee07dc18ff60df711156d0e45c4039e88d..558809ee308d69d7c9890547548a2c249bd7a292 100644 (file)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -1706,11 +1706,11 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
             BIO_printf(bio_err, "Memory allocation failure\n");
             goto end;
         }
+        i = -1;
         while ((i = X509_NAME_get_index_by_NID(dn_subject,
                                                NID_pkcs9_emailAddress,
-                                               -1)) >= 0) {
-            tmpne = X509_NAME_get_entry(dn_subject, i);
-            X509_NAME_delete_entry(dn_subject, i);
+                                               i)) >= 0) {
+            tmpne = X509_NAME_delete_entry(dn_subject, i--);
             X509_NAME_ENTRY_free(tmpne);
         }