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
This commit is contained in:
rofl0r 2012-12-17 22:17:00 +01:00
parent b255484a42
commit ce655fdac8
3 changed files with 19 additions and 11 deletions

View File

@ -15,7 +15,8 @@ sysconfdir=$(prefix)/etc
SRCS = $(sort $(wildcard src/*.c)) SRCS = $(sort $(wildcard src/*.c))
OBJS = $(SRCS:.c=.o) 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/allocator_thread.o src/ip_type.o src/stringdump.o \
src/hostentdb.o src/hash.o src/hostentdb.o src/hash.o

View File

@ -381,22 +381,16 @@ void freeaddrinfo(struct addrinfo *res) {
return; return;
} }
// work around a buggy prototype in GLIBC. according to the bugtracker it has been fixed in git at 02 May 2011. int pc_getnameinfo(const struct sockaddr *sa, socklen_t salen,
// 2.14 came out in June 2011 so that should be the first fixed version char *host, socklen_t hostlen, char *serv,
#if defined(__GLIBC__) && (__GLIBC__ < 3) && (__GLIBC_MINOR__ < 14) socklen_t servlen, int flags)
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
{ {
char ip_buf[16]; char ip_buf[16];
int ret = 0; int ret = 0;
INIT(); INIT();
PDEBUG("getnameinfo: %s %s\n", host, serv); PFUNC();
if(!proxychains_resolver) { if(!proxychains_resolver) {
ret = true_getnameinfo(sa, salen, host, hostlen, serv, servlen, flags); ret = true_getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);

13
src/nameinfo.c Normal file
View File

@ -0,0 +1,13 @@
#include <sys/socket.h>
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);
}