getaddrinfo: __resolv_conf_allocate: Assertion `conf == ptr' failed
Hi, I have a code that needs to resolve a name to IP. This code is already working in a lot of different distros and versions for a long time, but when I try to run in a freshly installed Ubuntu 18.04.1 (4.15.0-34-generic #37-Ubuntu SMP Mon Aug 27 15:21:48 UTC 2018 x86_64 x86_64 x86_64), and my /etc/resolv.conf has a line "search anyname.???" where ??? can be any group of three letters I get the following error:
Electric Fence 2.2 Copyright (C) 1987-1999 Bruce Perens <email address hidden>
Resolving for Host: <aaa>, Port: <5000>
resolv: resolv_conf.c:423: __resolv_
Aborted (core dumped)
It's also important to mention, that Electric Fence (-lefence) must be used.
I've included the code that causes the error, it happens when I call getaddrinfo
Thanks.
char buffer[128];
struct addrinfo hints;
struct addrinfo *result, *rp;
struct sockaddr_in *address;
if (argc < 2) {
printf("Error: Resolve <host> <port>\n");
exit(1);
}
char *p = (char*) malloc(120);
printf("Resolving for Host: <%s>, Port: <%s>\n", argv[1], argv[2]);
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_canonname = NULL;
hints.ai_addr = NULL;
hints.ai_next = NULL;
//hints.ai_family = AF_UNSPEC;
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_NUMERICSERV;
if (getaddrinfo(
printf("Failed to call getaddrinfo.\n");
exit(1);
}
Question information
- Language:
- English Edit question
- Status:
- Expired
- For:
- Ubuntu Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply: