From c99d97983e66e80869416f010b6730ca98de8b01 Mon Sep 17 00:00:00 2001 From: rofl0r Date: Mon, 26 Oct 2020 02:53:29 +0000 Subject: [PATCH] shrink huge gethostbyname buffer careful analysis has shown that the buffer is only ever used for at most a single hostname, so 256 bytes are sufficient. the huge 8KB buffer caused stack overflow when used with microsocks, which defaults to tiny thread stacks of 8KB with musl libc. --- src/core.c | 2 +- src/core.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core.c b/src/core.c index c307cbe..f5e7ce9 100644 --- a/src/core.c +++ b/src/core.c @@ -749,7 +749,7 @@ struct hostent* proxy_gethostbyname_old(const char *name) static struct hostent hostent_space; static in_addr_t resolved_addr; static char* resolved_addr_p; - static char addr_name[1024*8]; + static char addr_name[256]; int pipe_fd[2]; char buff[256]; diff --git a/src/core.h b/src/core.h index d54806d..acb0152 100644 --- a/src/core.h +++ b/src/core.h @@ -117,7 +117,7 @@ struct gethostbyname_data { struct hostent hostent_space; in_addr_t resolved_addr; char *resolved_addr_p[2]; - char addr_name[1024 * 8]; + char addr_name[256]; }; struct hostent* proxy_gethostbyname(const char *name, struct gethostbyname_data *data);