mirror of
https://github.com/haad/proxychains.git
synced 2026-09-14 11:05:48 +05:00
Fix couple of problems introduced/detected by clang checker and new -fno-common compiler flag.
This commit is contained in:
parent
462e34f447
commit
cca0cea44a
4
Makefile
4
Makefile
@ -17,7 +17,7 @@ SRCS = $(sort $(wildcard src/*.c))
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
LOBJS = src/core.o src/common.o src/libproxychains.o
|
||||
|
||||
CCFLAGS = -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror -Wextra -Wunused -Wuninitialized -Wconversion
|
||||
CCFLAGS = -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror -Wextra -Wunused -Wuninitialized -Wconversion -fno-common
|
||||
LDFLAGS = -shared -fPIC -ldl -lpthread
|
||||
INC =
|
||||
PIC = -fPIC
|
||||
@ -68,4 +68,4 @@ $(LDSO_PATHNAME): $(LOBJS)
|
||||
$(ALL_TOOLS): $(OBJS)
|
||||
$(CC) src/main.o src/common.o -o $(PXCHAINS)
|
||||
|
||||
.PHONY: all clean install install-config
|
||||
.PHONY: all clean install install-config
|
||||
|
||||
32
src/core.c
32
src/core.c
@ -34,10 +34,15 @@
|
||||
#include <sys/time.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef THREAD_SAFE
|
||||
#include <pthread.h>
|
||||
pthread_mutex_t internal_ips_lock;
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
pthread_mutex_t internal_getsrvbyname_lock;
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
#endif /* THREAD_SAFE */
|
||||
|
||||
#include "core.h"
|
||||
#include "common.h"
|
||||
@ -255,7 +260,7 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
|
||||
if(!dns_len)
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
PDEBUG("host dns %s\n", dns_name ? dns_name : "<NULL>");
|
||||
|
||||
size_t ulen = strlen(user);
|
||||
@ -617,7 +622,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
||||
|
||||
switch (ct) {
|
||||
case DYNAMIC_TYPE:
|
||||
alive_count = calc_alive(pd, proxy_count);
|
||||
calc_alive(pd, proxy_count);
|
||||
offset = 0;
|
||||
do {
|
||||
if(!(p1 = select_proxy(FIFOLY, pd, proxy_count, &offset)))
|
||||
@ -641,7 +646,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
||||
break;
|
||||
|
||||
case STRICT_TYPE:
|
||||
alive_count = calc_alive(pd, proxy_count);
|
||||
calc_alive(pd, proxy_count);
|
||||
offset = 0;
|
||||
if(!(p1 = select_proxy(FIFOLY, pd, proxy_count, &offset))) {
|
||||
PDEBUG("select_proxy failed\n");
|
||||
@ -830,19 +835,24 @@ void proxy_getserverbyname(const char * service, struct servent *se_buf,
|
||||
|
||||
#ifdef __APPLE__
|
||||
struct servent *se;
|
||||
|
||||
#ifdef THREAD_SAFE
|
||||
MUTEX_LOCK(&internal_getsrvbyname_lock);
|
||||
#endif
|
||||
if(service)
|
||||
if(service) {
|
||||
se = getservbyname(service, NULL);
|
||||
if (!se)
|
||||
memcpy(se_buf, se, buf_len);
|
||||
*se_result = se_buf;
|
||||
|
||||
if ( se != NULL ) {
|
||||
memcpy(se_buf, se, buf_len);
|
||||
*se_result = se_buf;
|
||||
} else {
|
||||
*se_result = NULL;
|
||||
}
|
||||
}
|
||||
#ifdef THREAD_SAFE
|
||||
MUTEX_UNLOCK(&internal_getsrvbyname_lock);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* __APPLE__ */
|
||||
}
|
||||
|
||||
int proxy_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res) {
|
||||
|
||||
12
src/core.h
12
src/core.h
@ -41,11 +41,9 @@ extern internal_ip_lookup_table internal_ips;
|
||||
|
||||
#ifdef THREAD_SAFE
|
||||
#include <pthread.h>
|
||||
pthread_mutex_t internal_ips_lock;
|
||||
|
||||
#ifdef __APPLE__
|
||||
pthread_mutex_t internal_getsrvbyname_lock;
|
||||
#endif
|
||||
extern pthread_mutex_t internal_ips_lock;
|
||||
extern pthread_mutex_t internal_getsrvbyname_lock;
|
||||
|
||||
# define MUTEX_LOCK(x) pthread_mutex_lock(x)
|
||||
# define MUTEX_UNLOCK(x) pthread_mutex_unlock(x)
|
||||
@ -115,10 +113,10 @@ typedef struct hostent* (*gethostbyname_t)(const char *);
|
||||
typedef int (*freeaddrinfo_t)(struct addrinfo *);
|
||||
typedef struct hostent *(*gethostbyaddr_t) (const void *, socklen_t, int);
|
||||
|
||||
typedef int (*getaddrinfo_t)(const char *, const char *, const struct addrinfo *,
|
||||
typedef int (*getaddrinfo_t)(const char *, const char *, const struct addrinfo *,
|
||||
struct addrinfo **);
|
||||
|
||||
typedef int (*getnameinfo_t) (const struct sockaddr *, socklen_t, char *,
|
||||
typedef int (*getnameinfo_t) (const struct sockaddr *, socklen_t, char *,
|
||||
socklen_t, char *, socklen_t, int);
|
||||
|
||||
|
||||
@ -138,7 +136,7 @@ struct gethostbyname_data {
|
||||
|
||||
struct hostent* proxy_gethostbyname(const char *name, struct gethostbyname_data *data);
|
||||
|
||||
int proxy_getaddrinfo(const char *node, const char *service,
|
||||
int proxy_getaddrinfo(const char *node, const char *service,
|
||||
const struct addrinfo *hints, struct addrinfo **res);
|
||||
void proxy_freeaddrinfo(struct addrinfo *res);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user