Fix a stupid bug (double ptr instead of one ptr)

This commit is contained in:
Quentin Dufour 2019-03-27 09:59:25 +01:00
parent 9f4882eb67
commit d06da2faa2

View file

@ -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) { int socks5_server_reply_atyp_ipv4(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
struct socks5_ctx* s5ctx = fdinfo->other; 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); size_t host_size = sizeof(s5ctx->sr.bind_addr.ipv4);
uint64_t relative_cursor = (s5ctx->sr_cursor - fixed_headers_size); uint64_t relative_cursor = (s5ctx->sr_cursor - fixed_headers_size);
int nread = 0; 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) { int socks5_server_reply_atyp_ipv6(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
struct socks5_ctx* s5ctx = fdinfo->other; 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); size_t host_size = sizeof(s5ctx->sr.bind_addr.ipv6);
uint64_t relative_cursor = (s5ctx->sr_cursor - fixed_headers_size); uint64_t relative_cursor = (s5ctx->sr_cursor - fixed_headers_size);
int nread = 0; 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) { int socks5_server_reply_atyp_dn(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
struct socks5_ctx* s5ctx = fdinfo->other; 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); size_t dn_size_size = sizeof(s5ctx->sr.bind_addr.dns.len);
uint64_t relative_cursor = 0; uint64_t relative_cursor = 0;
int nread = 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 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 fixed_tail_size = (char*)(sr + 1) - (char*)&sr->port;
size_t host_size = 0; size_t host_size = 0;