From d28cf03c61335da58bc8ee5e7790e90458554898 Mon Sep 17 00:00:00 2001 From: Adam Hamsik Date: Fri, 27 Jan 2012 16:26:51 +0100 Subject: [PATCH] Replace inet_ntoa which is not thread safe by re-entrant threadsafe inet_ntop. --- Makefile | 2 +- src/libproxychains.c | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 2360d2b..c68f876 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ SRCS = $(sort $(wildcard src/*.c)) OBJS = $(SRCS:.c=.o) LOBJS = src/core.o src/libproxychains.o -CCFLAGS = -Wall -O0 -g -std=c99 -D_GNU_SOURCE -D_BSD_SOURCE -pipe -DTHREAD_SAFE -Werror +CCFLAGS = -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror LDFLAGS = -shared -fPIC -ldl -lpthread INC = PIC = -fPIC diff --git a/src/libproxychains.c b/src/libproxychains.c index 3d4d968..a81959d 100644 --- a/src/libproxychains.c +++ b/src/libproxychains.c @@ -18,9 +18,6 @@ #undef _GNU_SOURCE #define _GNU_SOURCE -#undef _BSD_SOURCE -#define _BSD_SOURCE - #include #include @@ -456,9 +453,6 @@ struct hostent *gethostbyaddr (const void *addr, socklen_t len, int type) static char ipv4[4]; static char* list[2]; static struct hostent he; - struct in_addr ip; - - memcpy((void *) &ip, addr, sizeof(struct in_addr)); if(!init_l) init_lib(); @@ -480,7 +474,7 @@ struct hostent *gethostbyaddr (const void *addr, socklen_t len, int type) he.h_addrtype = AF_INET; he.h_aliases = NULL; he.h_length = 4; - snprintf(buf, 16, "%s", inet_ntoa(ip)); + inet_ntop(AF_INET, addr, buf, sizeof(buf)); return &he; } return NULL;