Replace inet_ntoa which is not thread safe by re-entrant threadsafe inet_ntop.

This commit is contained in:
Adam Hamsik 2012-01-27 16:26:51 +01:00
parent 952a039801
commit d28cf03c61
2 changed files with 2 additions and 8 deletions

View File

@ -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

View File

@ -18,9 +18,6 @@
#undef _GNU_SOURCE
#define _GNU_SOURCE
#undef _BSD_SOURCE
#define _BSD_SOURCE
#include <sys/types.h>
#include <dlfcn.h>
@ -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;