mirror of
https://github.com/rofl0r/proxychains-ng.git
synced 2025-09-09 01:46:55 +00:00
failed attempt to use shared memory for the ip <-> dns mapping
this is in order to get irssi, which forks for DNS lookups, and similar programs, to work as intended. in a previous attempt i learned that shared memory created in a child process is not visible to the parent; in this attempt i spin off a thread from the parent which listens on a pipe and manages the shared memory allocation from the parent address-space. however this doesnt work as expected: memory allocated in the parent after the child forked is not visi- ble to the child as well. so what happens is: irssi starts a child process, the thread allocs memory and hands it to the child, the child attempts to write and segfaults. however irssi doesnt crash. since now the memory is already allocated, doing the dns lookup again will succeed. i.e. the dns lookup works now in irssi by luck. all but the first dns lookups will suceed. however this is not good enough for me to be satisfied, i commit this only for documentation purposes.
This commit is contained in:
16
src/core.h
16
src/core.h
@ -14,6 +14,7 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/types.h>
|
||||
@ -35,13 +36,20 @@ typedef struct {
|
||||
char* string;
|
||||
} string_hash_tuple;
|
||||
|
||||
struct mallocinfo {
|
||||
void * addr;
|
||||
size_t oldsz;
|
||||
size_t newsz;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint32_t counter;
|
||||
uint32_t capa;
|
||||
struct mallocinfo mi;
|
||||
string_hash_tuple** list;
|
||||
} internal_ip_lookup_table;
|
||||
|
||||
extern internal_ip_lookup_table internal_ips;
|
||||
extern internal_ip_lookup_table *internal_ips;
|
||||
#ifdef THREAD_SAFE
|
||||
#include <pthread.h>
|
||||
extern pthread_mutex_t internal_ips_lock;
|
||||
@ -143,11 +151,7 @@ void proxy_freeaddrinfo(struct addrinfo *res);
|
||||
|
||||
void pc_stringfromipv4(unsigned char *ip_buf_4_bytes, char *outbuf_16_bytes);
|
||||
|
||||
#ifdef DEBUG
|
||||
# define PDEBUG(fmt, args...) do { fprintf(stderr,"DEBUG:"fmt, ## args); fflush(stderr); } while(0)
|
||||
#else
|
||||
# define PDEBUG(fmt, args...) do {} while (0)
|
||||
#endif
|
||||
#include "debug.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user