From: Willem Toorop Date: Sun, 7 Oct 2012 09:42:10 +0000 (+0000) Subject: bugfix 473. X-Git-Tag: release-1.6.14rc1~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4c85364cd9da095b2439d8181bb8684d154a782;p=thirdparty%2Fldns.git bugfix 473. - Fix unnecessary opening and closing of file in read_hex_buffer in drill/work.c. - Close input_file in read_key_file - Signed return type of possibly -1 returning read_line --- diff --git a/drill/drill_util.c b/drill/drill_util.c index 8326f133..826870b3 100644 --- a/drill/drill_util.c +++ b/drill/drill_util.c @@ -13,7 +13,7 @@ #include -static size_t +static int read_line(FILE *input, char *line, size_t len) { size_t i; @@ -71,6 +71,7 @@ read_key_file(const char *filename, ldns_rr_list *key_list) } } printf(";; Number of trusted keys: %d\n", key_count); + fclose(input_file); if (key_count > 0) { return LDNS_STATUS_OK; } else { diff --git a/drill/work.c b/drill/work.c index 339907b0..653145fe 100644 --- a/drill/work.c +++ b/drill/work.c @@ -173,20 +173,7 @@ read_hex_buffer(char *filename) size_t wiresize; ldns_buffer *result_buffer = NULL; - FILE *fp = NULL; - - if (strncmp(filename, "-", 2) != 0) { - fp = fopen(filename, "r"); - } else { - fp = stdin; - } - - if (fp == NULL) { - perror(""); - warning("Unable to open %s", filename); - return NULL; - } - + wire = xmalloc(LDNS_MAX_PACKETLEN); wiresize = packetbuffromfile(filename, wire); @@ -194,12 +181,8 @@ read_hex_buffer(char *filename) result_buffer = LDNS_MALLOC(ldns_buffer); ldns_buffer_new_frm_data(result_buffer, wire, wiresize); ldns_buffer_set_position(result_buffer, ldns_buffer_capacity(result_buffer)); - xfree(wire); - if (fp != stdin) { - fclose(fp); - } return result_buffer; } diff --git a/ldns/dnssec_zone.h b/ldns/dnssec_zone.h index 4d2642fd..70c81b04 100644 --- a/ldns/dnssec_zone.h +++ b/ldns/dnssec_zone.h @@ -8,7 +8,6 @@ #ifndef LDNS_DNSSEC_ZONE_H #define LDNS_DNSSEC_ZONE_H -#include #include #include diff --git a/ldns/keys.h b/ldns/keys.h index 089b55cf..fe6f4c3e 100644 --- a/ldns/keys.h +++ b/ldns/keys.h @@ -25,7 +25,6 @@ #if LDNS_BUILD_CONFIG_HAVE_SSL #include #endif /* LDNS_BUILD_CONFIG_HAVE_SSL */ -#include #include #include