Created
March 15, 2017 00:28
-
-
Save nchaimov/bbf7a665d18dd91753f812c3a65551a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _GNU_SOURCE | |
#define _GNU_SOURCE | |
#endif | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <arpa/inet.h> | |
#include <netdb.h> | |
#include <string.h> | |
#include <dlfcn.h> | |
int getaddrinfo(const char *node, const char *service, | |
const struct addrinfo *hints, struct addrinfo **res) { | |
struct addrinfo my_hints; | |
memcpy(&my_hints, hints, sizeof(struct addrinfo)); | |
my_hints.ai_family = AF_UNSPEC; | |
int(*original_getaddrinfo)(const char *, const char *, const struct addrinfo *, struct addrinfo **); | |
original_getaddrinfo = (int (*)(const char *, const char *, const struct addrinfo *, struct addrinfo **)) | |
dlsym(RTLD_NEXT, "getaddrinfo"); | |
if(original_getaddrinfo == NULL) { | |
fprintf(stderr, "can't find getaddrinfo\n"); | |
abort(); | |
} | |
(*original_getaddrinfo)(node, service, &my_hints, res); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment