From a65c1629693b015342f9e6537d4cddefe086f3bc Mon Sep 17 00:00:00 2001 From: Max Lv Date: Thu, 29 Oct 2015 16:58:28 +0800 Subject: [PATCH] fix a typo --- src/server.c | 6 +++--- src/udprelay.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/server.c b/src/server.c index 507edd37..30eedfd4 100644 --- a/src/server.c +++ b/src/server.c @@ -569,7 +569,7 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents) struct sockaddr_in *addr = (struct sockaddr_in *)&storage; size_t in_addr_len = sizeof(struct in_addr); addr->sin_family = AF_INET; - if (r > in_addr_len + 3) { + if (r >= in_addr_len + 3) { addr->sin_addr = *(struct in_addr *)(server->buf + offset); dns_ntop(AF_INET, (const void *)(server->buf + offset), host, INET_ADDRSTRLEN); @@ -589,7 +589,7 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents) } else if ((atyp & ADDRTYPE_MASK) == 3) { // Domain name uint8_t name_len = *(uint8_t *)(server->buf + offset); - if (name_len + 4 < r) { + if (name_len + 4 <= r) { memcpy(host, server->buf + offset + 1, name_len); offset += name_len + 1; } else { @@ -627,7 +627,7 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents) struct sockaddr_in6 *addr = (struct sockaddr_in6 *)&storage; size_t in6_addr_len = sizeof(struct in6_addr); addr->sin6_family = AF_INET6; - if (r > in6_addr_len + 3) { + if (r >= in6_addr_len + 3) { addr->sin6_addr = *(struct in6_addr *)(server->buf + offset); dns_ntop(AF_INET6, (const void *)(server->buf + offset), host, INET6_ADDRSTRLEN); diff --git a/src/udprelay.c b/src/udprelay.c index c6d54a38..da3b8f15 100644 --- a/src/udprelay.c +++ b/src/udprelay.c @@ -232,7 +232,7 @@ static int parse_udprealy_header(const char * buf, const int buf_len, if ((atyp & ADDRTYPE_MASK) == 1) { // IP V4 size_t in_addr_len = sizeof(struct in_addr); - if (buf_len > in_addr_len + 3) { + if (buf_len >= in_addr_len + 3) { if (storage != NULL) { struct sockaddr_in *addr = (struct sockaddr_in *)storage; addr->sin_family = AF_INET; @@ -248,7 +248,7 @@ static int parse_udprealy_header(const char * buf, const int buf_len, } else if ((atyp & ADDRTYPE_MASK) == 3) { // Domain name uint8_t name_len = *(uint8_t *)(buf + offset); - if (name_len + 4 < buf_len) { + if (name_len + 4 <= buf_len) { if (storage != NULL) { char tmp[256] = { 0 }; struct cork_ip ip; @@ -275,7 +275,7 @@ static int parse_udprealy_header(const char * buf, const int buf_len, } else if ((atyp & ADDRTYPE_MASK) == 4) { // IP V6 size_t in6_addr_len = sizeof(struct in6_addr); - if (buf_len > in6_addr_len + 3) { + if (buf_len >= in6_addr_len + 3) { if (storage != NULL) { struct sockaddr_in6 *addr = (struct sockaddr_in6 *)storage; addr->sin6_family = AF_INET6;