diff --git a/src/server.c b/src/server.c index 7c591a2..c91315e 100644 --- a/src/server.c +++ b/src/server.c @@ -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); @@ -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];