From ce655fdac82ed843b94a1f1a176475e9dbe432c1 Mon Sep 17 00:00:00 2001 From: rofl0r Date: Mon, 17 Dec 2012 22:17:00 +0100 Subject: [PATCH] fix the never-ending issues with the wrong glibc prototype of getnameinfo this bug was fixed shortly before 2.14 release, so we checked for that. however some distros decided to backport this fix to earlier versions, breaking our compiletime check. http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=e4ecafe004b3d4270b3a9dace8f970047400ed38 the portable solution is to stick the function into a separate comilation unit that does not see the glibc prototype. closes #7 --- Makefile | 3 ++- src/libproxychains.c | 14 ++++---------- src/nameinfo.c | 13 +++++++++++++ 3 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 src/nameinfo.c diff --git a/Makefile b/Makefile index 481d904..a814539 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,8 @@ sysconfdir=$(prefix)/etc SRCS = $(sort $(wildcard src/*.c)) OBJS = $(SRCS:.c=.o) -LOBJS = src/core.o src/common.o src/libproxychains.o src/shm.o \ +LOBJS = src/nameinfo.o \ + src/core.o src/common.o src/libproxychains.o src/shm.o \ src/allocator_thread.o src/ip_type.o src/stringdump.o \ src/hostentdb.o src/hash.o diff --git a/src/libproxychains.c b/src/libproxychains.c index 41b193b..d1ecd47 100644 --- a/src/libproxychains.c +++ b/src/libproxychains.c @@ -381,22 +381,16 @@ void freeaddrinfo(struct addrinfo *res) { return; } -// work around a buggy prototype in GLIBC. according to the bugtracker it has been fixed in git at 02 May 2011. -// 2.14 came out in June 2011 so that should be the first fixed version -#if defined(__GLIBC__) && (__GLIBC__ < 3) && (__GLIBC_MINOR__ < 14) -int getnameinfo(const struct sockaddr *sa, - socklen_t salen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, unsigned int flags) -#else -int getnameinfo(const struct sockaddr *sa, - socklen_t salen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, int flags) -#endif +int pc_getnameinfo(const struct sockaddr *sa, socklen_t salen, + char *host, socklen_t hostlen, char *serv, + socklen_t servlen, int flags) { char ip_buf[16]; int ret = 0; INIT(); - PDEBUG("getnameinfo: %s %s\n", host, serv); + PFUNC(); if(!proxychains_resolver) { ret = true_getnameinfo(sa, salen, host, hostlen, serv, servlen, flags); diff --git a/src/nameinfo.c b/src/nameinfo.c new file mode 100644 index 000000000..2a532a2 --- /dev/null +++ b/src/nameinfo.c @@ -0,0 +1,13 @@ +#include + +extern int pc_getnameinfo(const void *sa, socklen_t salen, + char *host, socklen_t hostlen, char *serv, + socklen_t servlen, int flags); + + +int getnameinfo(const void *sa, socklen_t salen, + char *host, socklen_t hostlen, char *serv, + socklen_t servlen, int flags) { + return pc_getnameinfo(sa, salen, host, hostlen, serv, servlen, flags); +} +