From: Nikos Mavrogiannopoulos Date: Sat, 23 Aug 2014 03:44:22 +0000 (+0200) Subject: danetool: ensure the temporary file is always removed X-Git-Tag: gnutls_3_4_0~1042 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f862f3bbb53928bb2c0d4d35da6e7f4f8f56f608;p=thirdparty%2Fgnutls.git danetool: ensure the temporary file is always removed --- diff --git a/src/danetool.c b/src/danetool.c index a3e786f42a..4e30d4c029 100644 --- a/src/danetool.c +++ b/src/danetool.c @@ -226,7 +226,8 @@ static void dane_check(const char *host, const char *proto, if (ret < 0) { fprintf(stderr, "dane_state_init: %s\n", dane_strerror(ret)); - exit(1); + retcode = 1; + goto error; } if (HAVE_OPT(DLV)) { @@ -234,7 +235,8 @@ static void dane_check(const char *host, const char *proto, if (ret < 0) { fprintf(stderr, "dane_state_set_dlv_file: %s\n", dane_strerror(ret)); - exit(1); + retcode = 1; + goto error; } } @@ -242,7 +244,8 @@ static void dane_check(const char *host, const char *proto, if (ret < 0) { fprintf(stderr, "dane_query_tlsa: %s\n", dane_strerror(ret)); - exit(1); + retcode = 1; + goto error; } if (ENABLED_OPT(PRINT_RAW)) { @@ -258,7 +261,8 @@ static void dane_check(const char *host, const char *proto, if (ret < 0) { fprintf(stderr, "dane_query_to_raw_tlsa: %s\n", dane_strerror(ret)); - exit(1); + retcode = 1; + goto error; } for (i=0;i 0) { @@ -316,7 +323,8 @@ static void dane_check(const char *host, const char *proto, "gnutls_x509_crt_export2: %s\n", gnutls_strerror (ret)); - exit(1); + retcode = 1; + goto error; } } } @@ -324,13 +332,12 @@ static void dane_check(const char *host, const char *proto, entries = dane_query_entries(q); for (i = 0; i < entries; i++) { - del = 0; - ret = dane_query_data(q, i, &usage, &type, &match, &data); if (ret < 0) { fprintf(stderr, "dane_query_data: %s\n", dane_strerror(ret)); - exit(1); + retcode = 1; + goto error; } size = lbuffer_size; @@ -338,7 +345,8 @@ static void dane_check(const char *host, const char *proto, if (ret < 0) { fprintf(stderr, "gnutls_hex_encode: %s\n", dane_strerror(ret)); - exit(1); + retcode = 1; + goto error; } if (entries > 1 && !HAVE_OPT(QUIET)) @@ -377,7 +385,8 @@ static void dane_check(const char *host, const char *proto, fprintf(stderr, "dane_verify_crt: %s\n", dane_strerror(ret)); - exit(1); + retcode = 1; + goto error; } ret = @@ -388,7 +397,8 @@ static void dane_check(const char *host, const char *proto, fprintf(stderr, "dane_verification_status_print: %s\n", dane_strerror(ret)); - exit(1); + retcode = 1; + goto error; } if (!HAVE_OPT(QUIET)) @@ -412,14 +422,16 @@ static void dane_check(const char *host, const char *proto, gnutls_free(clist); } - if (del != 0 && cinfo->cert) { - remove(cinfo->cert); - } dane_query_deinit(q); dane_state_deinit(s); + error: + if (del != 0 && cinfo->cert) { + remove(cinfo->cert); + } + exit(retcode); #else fprintf(stderr,