X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=src%2Ftlsproxy.c;h=8b9b6d92e1bb3309010b54a7240900a23419268c;hb=8c4ae426c578d53c7afcbcbc178c96a7da3614c2;hp=b391b738e641d1314db5c8289fefa62e694379a9;hpb=1d65b2374b94b6191d7c3ca53632c9ea416b2b7b;p=tlsproxy%2Ftlsproxy.git diff --git a/src/tlsproxy.c b/src/tlsproxy.c index b391b73..8b9b6d9 100644 --- a/src/tlsproxy.c +++ b/src/tlsproxy.c @@ -237,7 +237,7 @@ int main(int argc, char **argv) { free(global_proxy_host); free(global_proxy_port); - free(http_digest_authorization); + free(global_http_digest_authorization); return EXIT_FAILURE; } @@ -265,20 +265,20 @@ static void parse_arguments(int argc, char **argv) { while ((option = getopt(argc, argv, "a:d:p:t:uh?")) != -1) { switch (option) { case 'a': { - http_digest_authorization = slurp_text_file(optarg); - if (http_digest_authorization == NULL) { + global_http_digest_authorization = slurp_text_file(optarg); + if (global_http_digest_authorization == NULL) { fprintf(stderr, "failed to open authorization file '%s': ", optarg); perror(""); exit(EXIT_FAILURE); - } else if (strlen(http_digest_authorization) == 0) { + } else if (strlen(global_http_digest_authorization) == 0) { fprintf(stderr, "empty authorization file '%s'\n", optarg); exit(EXIT_FAILURE); } /* Just in case the file has a trailing newline. */ - strtok(http_digest_authorization, "\r\n"); + strtok(global_http_digest_authorization, "\r\n"); break; } @@ -375,7 +375,7 @@ static void initialize_gnutls(void) { gnutls_datum_t dh_parameters_datum; /* Recent versions of GnuTLS automatically initialize the cryptography layer - * in gnutls_global_init(). */ + * in gnutls_global_init(), including a thread-safe setup. */ #if GNUTLS_VERSION_NUMBER <= 0x020b00 gcry_error_t error; @@ -395,6 +395,12 @@ static void initialize_gnutls(void) { } #endif + if (gnutls_check_version(GNUTLS_VERSION) == NULL) { + fprintf(stderr, "gnutls_check_version(): version mismatch, " + "expected at least '" GNUTLS_VERSION "'\n"); + exit(EXIT_FAILURE); + } + /* Initialize GnuTLS. */ result = gnutls_global_init(); GNUTLS_ERROR_EXIT(result, "gnutls_global_init()");