From adce8f681c2cc6d8694c6d0498863282cf6ae7bf Mon Sep 17 00:00:00 2001 From: Max Lv Date: Fri, 28 Dec 2012 10:44:38 +0800 Subject: [PATCH] fix bugs --- local.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/local.c b/local.c index 73443551..a547bcdd 100644 --- a/local.c +++ b/local.c @@ -109,7 +109,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) { int *buf_len = &remote->buf_len; if (server->stage != 5) { buf = server->buf; - buf_len = server->buf_len; + buf_len = &server->buf_len; } while (1) { @@ -197,16 +197,9 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) { if (request->atyp == 1) { // IP V4 - struct in_addr *in_addr; - in_addr = (struct in_addr *)(server->buf + 4); - char* addr_buf = inet_ntoa(*in_addr); - unsigned char name_len = strlen(addr_buf); - memcpy(addr_to_send + addr_len, addr_buf, name_len); - addr_len += name_len; - - // get port - addr_to_send[addr_len++] = *(unsigned char *)(server->buf + 4 + 4); - addr_to_send[addr_len++] = *(unsigned char *)(server->buf + 4 + 4 + 1); + size_t in_addr_len = sizeof(struct in_addr); + memcpy(addr_to_send + addr_len, server->buf + 4, in_addr_len + 2); + addr_len += in_addr_len + 2; addr_to_send[addr_len] = 0; } else if (request->atyp == 3) {