blob: 26863fd9245258a07eb43a7bbc1dd7f2a5d672fb [file] [log] [blame]
Bernie Innocentif89b3512018-08-30 07:34:37 +09001#ifndef _RESOLV_STATIC_H_
2#define _RESOLV_STATIC_H_
Bernie Innocenti55864192018-08-30 04:05:20 +09003
4#include <netdb.h>
5
6/* this structure contains all the variables that were declared
7 * 'static' in the original NetBSD resolver code.
8 *
9 * this caused vast amounts of crashes and memory corruptions
10 * when the resolver was being used by multiple threads.
11 *
12 * (note: the OpenBSD/FreeBSD resolver has similar 'issues')
13 */
14
Bernie Innocentif12d5bb2018-08-31 14:09:46 +090015#define MAXALIASES 35
16#define MAXADDRS 35
Bernie Innocenti55864192018-08-30 04:05:20 +090017
18typedef struct res_static {
Bernie Innocentif12d5bb2018-08-31 14:09:46 +090019 char* h_addr_ptrs[MAXADDRS + 1];
20 char* host_aliases[MAXALIASES];
21 char hostbuf[8 * 1024];
22 u_int32_t host_addr[16 / sizeof(u_int32_t)]; /* IPv4 or IPv6 */
23 FILE* hostf;
24 int stayopen;
25 const char* servent_ptr;
26 struct servent servent;
27 struct hostent host;
28} * res_static;
Bernie Innocenti55864192018-08-30 04:05:20 +090029
30extern res_static __res_get_static(void);
31
Bernie Innocentif89b3512018-08-30 07:34:37 +090032#endif // _RESOLV_STATIC_H_