From 539b400228f142ec797266f81473dfc2a792a3d7 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sat, 15 Jun 2013 10:08:18 +0800 Subject: [PATCH] fix ntop --- src/server.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/server.c b/src/server.c index b848c18a..505c6438 100644 --- a/src/server.c +++ b/src/server.c @@ -220,7 +220,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) { // IP V4 size_t in_addr_len = sizeof(struct in_addr); if (r > in_addr_len) { - inet_ntop(AF_INET, (void *)server->buf[offset], + inet_ntop(AF_INET, (void *)(server->buf + offset), host, in_addr_len); offset += in_addr_len; } @@ -239,10 +239,8 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) { // IP V6 size_t in6_addr_len = sizeof(struct in6_addr); if (r > in6_addr_len) { - char a[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, (const void*)(server->buf + offset), - a, sizeof(a)); - memcpy(host, a, strlen(a)); + host, in6_addr_len); offset += in6_addr_len; }