summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dane.c8
-rw-r--r--examples/ldns-dane.c4
-rw-r--r--examples/ldns-keyfetcher.c8
3 files changed, 10 insertions, 10 deletions
diff --git a/dane.c b/dane.c
index 2819625b..3179793d 100644
--- a/dane.c
+++ b/dane.c
@@ -285,12 +285,10 @@ ldns_dane_get_nth_cert_from_validation_chain(
if (n >= sk_X509_num(chain) || n < 0) {
return LDNS_STATUS_DANE_OFFSET_OUT_OF_RANGE;
}
- for (;;) {
- *cert = sk_X509_pop(chain);
- if (n-- == 0) {
- break;
- }
+ *cert = sk_X509_pop(chain);
+ while (n-- > 0) {
X509_free(*cert);
+ *cert = sk_X509_pop(chain);
}
if (ca && ! X509_check_ca(*cert)) {
return LDNS_STATUS_DANE_NON_CA_CERTIFICATE;
diff --git a/examples/ldns-dane.c b/examples/ldns-dane.c
index 748ce30b..0e5a6c57 100644
--- a/examples/ldns-dane.c
+++ b/examples/ldns-dane.c
@@ -29,9 +29,9 @@
#include <openssl/x509v3.h>
#define LDNS_ERR(code, msg) do { if (code != LDNS_STATUS_OK) \
- ldns_err(msg, code); } while(0)
+ ldns_err(msg, code); } while (false)
#define MEMERR(msg) do { fprintf(stderr, "memory error in %s\n", msg); \
- exit(EXIT_FAILURE); } while(0)
+ exit(EXIT_FAILURE); } while (false)
#define BUFSIZE 16384
/* int verbosity = 3; */
diff --git a/examples/ldns-keyfetcher.c b/examples/ldns-keyfetcher.c
index ee06aea9..fa78b432 100644
--- a/examples/ldns-keyfetcher.c
+++ b/examples/ldns-keyfetcher.c
@@ -649,7 +649,7 @@ main(int argc, char *argv[])
fprintf(stderr, "Warning: Unable to create stub resolver from /etc/resolv.conf:\n");
fprintf(stderr, "%s\n", ldns_get_errorstr_by_id(status));
fprintf(stderr, "defaulting to nameserver at 127.0.0.1 for separate nameserver name lookups\n");
- for (;;) {
+ do {
res = ldns_resolver_new();
if (res) {
ns = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_A,
@@ -664,9 +664,11 @@ main(int argc, char *argv[])
}
ldns_resolver_free(res);
}
- fprintf(stderr, "Unable to create stub resolver: %s\n", ldns_get_errorstr_by_id(status));
+ fprintf(stderr, "Unable to create stub resolver: %s\n",
+ ldns_get_errorstr_by_id(status));
exit(EXIT_FAILURE);
- }
+
+ } while (false);
ldns_rdf_deep_free(ns);
}