X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=src%2Fconnection.c;h=8f78bba6c373a6078b5421bb5787d5bbcb73fdea;hb=04a443914e05704e6fcf58b738dcde5f75ce6a97;hp=a42fbe055ae9349094743344c9a5c814efc2b584;hpb=7482f10d37782bbca56237357323521f2d87ea54;p=tlsproxy%2Ftlsproxy.git diff --git a/src/connection.c b/src/connection.c index a42fbe0..8f78bba 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 @@ -72,7 +72,7 @@ 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 (-1 == result) { - /* Read error. */ + /* Read error, client_fd already closed. */ return; } else if (-2 == result) { /* EOF */ @@ -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; } @@ -121,7 +122,7 @@ void handle_connection(int client_socket) { /* Read response line from proxy server. */ result = read_http_request(server_fd, buffer, sizeof(buffer)); if (-1 == result) { - /* Read error. */ + /* Read error, server_fd already closed. */ send_close_forwarding_failure(client_fd); return; } else if (-2 == result) { @@ -270,8 +271,8 @@ static int read_from_write_to(int from, int to) { return -1; } if (size_read != size_written) { - printf("only written %ld of %ld bytes!\n", (long int)size_read, - (long int)size_written); + printf("only written %ld of %ld bytes!\n", (long int)size_written, + (long int)size_read); return -1; } @@ -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').