X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=src%2Fconnection.c;h=ec351b7cc4446551151428d3795fa68a18b2aa6b;hb=8f00cc8238c41fb6140b247363aeddf1e1bb7e02;hp=4160c7feff77388206b3459bf82f18c8f2734eeb;hpb=643caf202af98fa5ebe83f642db459a04067e92f;p=tlsproxy%2Ftlsproxy.git diff --git a/src/connection.c b/src/connection.c index 4160c7f..ec351b7 100644 --- a/src/connection.c +++ b/src/connection.c @@ -28,9 +28,9 @@ #include -/* Maximum line of the request line. Longer request lines are aborted with an - * error. The standard doesn't specify a maximum line length but this should - * be a good limit to make processing simpler. */ +/* Maximum line of a HTTP request line. Longer request lines are aborted with + * an error. The standard doesn't specify a maximum line length but this + * should be a good limit to make processing simpler. */ #define MAX_REQUEST_LINE 4096 @@ -71,10 +71,10 @@ void handle_connection(int client_socket) { /* Read request line (CONNECT ..) and headers (they are discarded). */ result = read_http_request(client_fd, buffer, sizeof(buffer)); - if (result == -1) { - /* Read error. */ + if (-1 == result) { + /* Read error, client_fd already closed. */ return; - } else if (result == -2) { + } else if (-2 == result) { /* EOF */ send_close_bad_request(client_fd); return; @@ -110,6 +110,7 @@ void handle_connection(int client_socket) { server_fd = fdopen(server_socket, "a+"); if (NULL == server_fd) { send_close_forwarding_failure(client_fd); + close(server_socket); return; } @@ -120,11 +121,11 @@ void handle_connection(int client_socket) { /* Read response line from proxy server. */ result = read_http_request(server_fd, buffer, sizeof(buffer)); - if (result == -1) { - /* Read error. */ + if (-1 == result) { + /* Read error, server_fd already closed. */ send_close_forwarding_failure(client_fd); return; - } else if (result == -2) { + } else if (-2 == result) { /* EOF */ fclose(server_fd); send_close_forwarding_failure(client_fd); @@ -338,7 +339,7 @@ static int connect_to_host(const char *hostname, const char *port) { /* Parse HTTP CONNECT request string and save its parameters. * - * The following format is expected: "CONNECT host:port HTTP/1.y". + * The following format is expected: "CONNECT host:port HTTP/1.x". * * request and host must have the same size! port must be at least 6 bytes * long (5 + '\0').