From 00e7ea205ca21258e5d99e6837485260b2e450b2 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Fri, 12 Jun 2015 13:37:59 +0800 Subject: [PATCH] check name_len in the header --- src/server.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/server.c b/src/server.c index 3a58f27d..5f04da4c 100644 --- a/src/server.c +++ b/src/server.c @@ -474,6 +474,11 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents) if (name_len < r && name_len < 255 && name_len > 0) { memcpy(host, server->buf + offset + 1, name_len); offset += name_len + 1; + } else { + LOGE("invalid name length: %d", name_len); + report_addr(server->fd); + close_and_free_server(EV_A_ server); + return; } struct cork_ip ip; if (cork_ip_init(&ip, host) != -1) {