From d06da2faa2400e71005d9f86ccc9bcbbcd3c6594 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Wed, 27 Mar 2019 09:59:25 +0100 Subject: [PATCH] Fix a stupid bug (double ptr instead of one ptr) --- src/socks5.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/socks5.c b/src/socks5.c index 6bb1e7f..a129cd4 100644 --- a/src/socks5.c +++ b/src/socks5.c @@ -132,7 +132,7 @@ int on_socks5_send_client_req(struct evt_core_ctx* ctx, struct evt_core_fdinfo* int socks5_server_reply_atyp_ipv4(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) { struct socks5_ctx* s5ctx = fdinfo->other; - size_t fixed_headers_size = (void*)&s5ctx->sr.bind_addr.ipv4 - (void*)&s5ctx->sr; + size_t fixed_headers_size = (char*)&s5ctx->sr.bind_addr.ipv4 - (char*)&s5ctx->sr; size_t host_size = sizeof(s5ctx->sr.bind_addr.ipv4); uint64_t relative_cursor = (s5ctx->sr_cursor - fixed_headers_size); int nread = 0; @@ -157,7 +157,7 @@ int socks5_server_reply_atyp_ipv4(struct evt_core_ctx* ctx, struct evt_core_fdin int socks5_server_reply_atyp_ipv6(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) { struct socks5_ctx* s5ctx = fdinfo->other; - size_t fixed_headers_size = (void*)&s5ctx->sr.bind_addr.ipv6 - (void*)&s5ctx->sr; + size_t fixed_headers_size = (char*)&s5ctx->sr.bind_addr.ipv6 - (char*)&s5ctx->sr; size_t host_size = sizeof(s5ctx->sr.bind_addr.ipv6); uint64_t relative_cursor = (s5ctx->sr_cursor - fixed_headers_size); int nread = 0; @@ -181,7 +181,7 @@ int socks5_server_reply_atyp_ipv6(struct evt_core_ctx* ctx, struct evt_core_fdin int socks5_server_reply_atyp_dn(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) { struct socks5_ctx* s5ctx = fdinfo->other; - size_t fixed_headers_size = (void*)&s5ctx->sr.bind_addr.ipv6 - (void*)&s5ctx->sr; + size_t fixed_headers_size = (char*)&s5ctx->sr.bind_addr.ipv6 - (char*)&s5ctx->sr; size_t dn_size_size = sizeof(s5ctx->sr.bind_addr.dns.len); uint64_t relative_cursor = 0; int nread = 0; @@ -215,7 +215,7 @@ int socks5_server_reply_atyp_dn(struct evt_core_ctx* ctx, struct evt_core_fdinfo } size_t socks5_server_reply_size(struct server_reply* sr) { - size_t fixed_headers_size = (char*)&sr->bind_addr - (char*)&sr; + size_t fixed_headers_size = (char*)&sr->bind_addr - (char*)sr; size_t fixed_tail_size = (char*)(sr + 1) - (char*)&sr->port; size_t host_size = 0;