X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=src%2Fconnection.c;h=36e03048943f9d6bc00f6f3f342f74f845a54e32;hb=62bffb28964ae13d193414f747a25703a2583f77;hp=710963c8f0bb96b4ab37d626b2d1bf0f0f04db1f;hpb=c5059d4c1e7f0de5a466d471e7ee26b6ccce8396;p=tlsproxy%2Ftlsproxy.git diff --git a/src/connection.c b/src/connection.c index 710963c..36e0304 100644 --- a/src/connection.c +++ b/src/connection.c @@ -21,14 +21,10 @@ #include "connection.h" #include "verify.h" -/* close() */ -#include -/* getaddrinfo() */ +#include #include -/* poll() */ #include -/* errno */ -#include +#include /* Maximum length of a HTTP request line. Longer request lines are aborted @@ -186,7 +182,7 @@ void handle_connection(int client_socket) { } /* Check response of proxy server. */ - if (strncmp(buffer, "HTTP/1.0 200", 12) != 0) { + if (strncmp(buffer, "HTTP/1.0 200", 12)) { LOG(LOG_WARNING, "bad proxy response: %s", buffer); send_forwarding_failure(client_fd); goto out; @@ -311,17 +307,17 @@ void handle_connection(int client_socket) { out: /* Close TLS sessions if necessary. Use GNUTLS_SHUT_RDWR so the data is * reliable transmitted. */ - if (server_session_started != 0) { + if (server_session_started) { gnutls_bye(server_session, GNUTLS_SHUT_RDWR); } - if (client_session_started != 0) { + if (client_session_started) { gnutls_bye(client_session, GNUTLS_SHUT_RDWR); } - if (server_session_init != 0) { + if (server_session_init) { gnutls_deinit(server_session); gnutls_certificate_free_credentials(server_x509_cred); } - if (client_session_init != 0) { + if (client_session_init) { gnutls_deinit(client_session); gnutls_certificate_free_cas(client_x509_cred); gnutls_certificate_free_keys(client_x509_cred); @@ -357,7 +353,7 @@ static int initialize_tls_session_client(int peer_socket, /* The "invalid" hostname is special. If it's used we send an invalid * certificate to let the client know something is wrong. */ - use_invalid_cert = (strcmp(hostname, "invalid") == 0); + use_invalid_cert = (!strcmp(hostname, "invalid")); if (proxy_certificate_path(hostname, path, sizeof(path)) != 0) { LOG(LOG_ERROR, @@ -514,7 +510,7 @@ static int read_http_request(FILE *client_fd, char *request, size_t length) { while (fgets(buffer, sizeof(buffer), client_fd) != NULL) { /* End of header. */ - if (strcmp(buffer, "\n") == 0 || strcmp(buffer, "\r\n") == 0) { + if (!strcmp(buffer, "\n") || !strcmp(buffer, "\r\n")) { break; } } @@ -821,7 +817,7 @@ static int parse_request(const char *request, char *host, char *port, char *position; /* scanf() doesn't check spaces. */ - if (strncmp(request, "CONNECT ", 8) != 0) { + if (strncmp(request, "CONNECT ", 8)) { return -1; } /* Check request and extract data, "host:port" is not yet separated. */