• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef NETD_RESOLV_STATIC_H
2 #define NETD_RESOLV_STATIC_H
3 
4 #include <netdb.h>
5 #include <stdio.h>
6 
7 /* this structure contains all the variables that were declared
8  * 'static' in the original NetBSD resolver code.
9  *
10  * this caused vast amounts of crashes and memory corruptions
11  * when the resolver was being used by multiple threads.
12  *
13  * (note: the OpenBSD/FreeBSD resolver has similar 'issues')
14  */
15 
16 #define MAXALIASES 35
17 #define MAXADDRS 35
18 
19 struct res_static {
20     char* h_addr_ptrs[MAXADDRS + 1];
21     char* host_aliases[MAXALIASES];
22     char hostbuf[8 * 1024];
23     u_int32_t host_addr[16 / sizeof(u_int32_t)]; /* IPv4 or IPv6 */
24     FILE* hostf;
25     int stayopen;
26     const char* servent_ptr;
27     struct servent servent;
28     struct hostent host;
29 };
30 
31 res_static* res_get_static();
32 
33 #endif  // NETD_RESOLV_STATIC_H
34