Skip to content

Commit

Permalink
The SOCKS request cannot be smaller than 4 bytes.
Browse files Browse the repository at this point in the history
  • Loading branch information
matricali committed Nov 28, 2019
1 parent 6730e9e commit 62eb7b1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ void zk_server_process_request(zk_server_connection_t cli_conn)

static char buffer[BUFSIZE + 1];


ret = zk_server_read(cli_conn, buffer, BUFSIZE);
if (ret == 0 || ret == -1) {
(void)close(cli_conn.sockfd);
Expand Down Expand Up @@ -97,6 +96,11 @@ void zk_server_process_request(zk_server_connection_t cli_conn)
ret = zk_server_read(cli_conn, buffer, BUFSIZE);
i = 0;

if (ret < 4) {
goto close_routine;
zk_logger(ZK_LOG_INFO, "Unsuported protocol.\n");
}

uint8_t protocol = buffer[0];
uint8_t command = buffer[1];
uint8_t rsv = buffer[2];
Expand Down

0 comments on commit 62eb7b1

Please sign in to comment.