Fix list pointer bug in proxy

This commit is contained in:
2023-01-12 01:58:14 +01:00
parent 820ce8dac9
commit 07d6280864
9 changed files with 23 additions and 29 deletions

View File

@ -23,7 +23,7 @@ typedef struct {
char cc[3], host[256];
char req_host[256], err_msg[256];
char log_prefix[128];
char _c_addr[ADDRSTRLEN + 1], _s_addr[ADDRSTRLEN + 1];
char _c_addr[INET6_ADDRSTRLEN + 1], _s_addr[INET6_ADDRSTRLEN + 1];
long cnx_s, cnx_e, req_s, res_ts, req_e;
http_req req;
http_res res;

View File

@ -14,7 +14,6 @@
#include "../workers.h"
#include <string.h>
#include <errno.h>
static int proxy_handler_1(client_ctx_t *ctx);
static int proxy_handler_2(client_ctx_t *ctx);

View File

@ -62,10 +62,8 @@ static void init_ctx(client_ctx_t *ctx) {
memset(&ctx->req, 0, sizeof(ctx->req));
memset(&ctx->res, 0, sizeof(ctx->res));
ctx->res.status = http_get_status(501);
http_init_hdr(&ctx->res.hdr);
ctx->res.hdr.last_field_num = -1;
sprintf(ctx->res.version, "1.1");
ctx->status.status = 0;

View File

@ -32,6 +32,8 @@ void tcp_acceptor_func(client_ctx_t *ctx) {
static int tcp_acceptor(client_ctx_t *ctx) {
struct sockaddr_in6 server_addr;
memset(ctx->_c_addr, 0, sizeof(ctx->_c_addr));
memset(ctx->_s_addr, 0, sizeof(ctx->_s_addr));
inet_ntop(ctx->socket._addr.ipv6.sin6_family, &ctx->socket._addr.ipv6.sin6_addr, ctx->_c_addr, sizeof(ctx->_c_addr));
if (strstarts(ctx->_c_addr, "::ffff:")) {
ctx->socket.addr = ctx->_c_addr + 7;