From 915047e957d5bd581be8e144ed92a1bb05441af5 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Fri, 5 Aug 2016 18:06:37 +0800 Subject: [PATCH] Fix #761 --- src/udprelay.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/udprelay.c b/src/udprelay.c index b76dfbd0..67e80767 100644 --- a/src/udprelay.c +++ b/src/udprelay.c @@ -645,7 +645,7 @@ static void remote_recv_cb(EV_P_ ev_io *w, int revents) memset(&src_addr, 0, src_addr_len); buffer_t *buf = ss_malloc(sizeof(buffer_t)); - balloc(buf, packet_size); + balloc(buf, buf_size); // recv r = recvfrom(remote_ctx->fd, buf->array, buf_size, 0, (struct sockaddr *)&src_addr, &src_addr_len); @@ -663,7 +663,7 @@ static void remote_recv_cb(EV_P_ ev_io *w, int revents) buf->len = r; #ifdef MODULE_LOCAL - int err = ss_decrypt_all(buf, server_ctx->method, 0, packet_size); + int err = ss_decrypt_all(buf, server_ctx->method, 0, buf_size); if (err) { // drop the packet silently goto CLEAN_UP; @@ -697,7 +697,7 @@ static void remote_recv_cb(EV_P_ ev_io *w, int revents) memmove(buf->array, buf->array + len, buf->len); #else // Construct packet - brealloc(buf, buf->len + 3, packet_size); + brealloc(buf, buf->len + 3, buf_size); memmove(buf->array + 3, buf->array, buf->len); memset(buf->array, 0, 3); buf->len += 3; @@ -718,12 +718,12 @@ static void remote_recv_cb(EV_P_ ev_io *w, int revents) } // Construct packet - brealloc(buf, buf->len + addr_header_len, packet_size); + brealloc(buf, buf->len + addr_header_len, buf_size); memmove(buf->array + addr_header_len, buf->array, buf->len); memcpy(buf->array, addr_header, addr_header_len); buf->len += addr_header_len; - int err = ss_encrypt_all(buf, server_ctx->method, 0, packet_size); + int err = ss_encrypt_all(buf, server_ctx->method, 0, buf_size); if (err) { // drop the packet silently goto CLEAN_UP; @@ -797,7 +797,7 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents) memset(&src_addr, 0, sizeof(struct sockaddr_storage)); buffer_t *buf = ss_malloc(sizeof(buffer_t)); - balloc(buf, packet_size); + balloc(buf, buf_size); socklen_t src_addr_len = sizeof(struct sockaddr_storage); unsigned int offset = 0; @@ -815,7 +815,7 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents) msg.msg_controllen = sizeof(control_buffer); iov[0].iov_base = buf->array; - iov[0].iov_len = packet_size; + iov[0].iov_len = buf_size; msg.msg_iov = iov; msg.msg_iovlen = 1; @@ -860,7 +860,7 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents) tx += buf->len; - int err = ss_decrypt_all(buf, server_ctx->method, server_ctx->auth, packet_size); + int err = ss_decrypt_all(buf, server_ctx->method, server_ctx->auth, buf_size); if (err) { // drop the packet silently goto CLEAN_UP; @@ -928,7 +928,7 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents) } // reconstruct the buffer - brealloc(buf, buf->len + addr_header_len, packet_size); + brealloc(buf, buf->len + addr_header_len, buf_size); memmove(buf->array + addr_header_len, buf->array, buf->len); memcpy(buf->array, addr_header, addr_header_len); buf->len += addr_header_len; @@ -982,7 +982,7 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents) addr_header_len += 2; // reconstruct the buffer - brealloc(buf, buf->len + addr_header_len, packet_size); + brealloc(buf, buf->len + addr_header_len, buf_size); memmove(buf->array + addr_header_len, buf->array, buf->len); memcpy(buf->array, addr_header, addr_header_len); buf->len += addr_header_len; @@ -1120,7 +1120,7 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents) buf->array[0] |= ONETIMEAUTH_FLAG; } - int err = ss_encrypt_all(buf, server_ctx->method, server_ctx->auth, packet_size); + int err = ss_encrypt_all(buf, server_ctx->method, server_ctx->auth, buf_size); if (err) { // drop the packet silently