blob: 87bdce21b119403bd2e443170e47279079a38778 [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>
Bernie Innocenti1f4a9fd2018-09-07 21:10:25 +09005#include <stdio.h>
Bernie Innocenti55864192018-08-30 04:05:20 +09006
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
Bernie Innocentif12d5bb2018-08-31 14:09:46 +090016#define MAXALIASES 35
17#define MAXADDRS 35
Bernie Innocenti55864192018-08-30 04:05:20 +090018
Bernie Innocenti1f4a9fd2018-09-07 21:10:25 +090019struct res_static {
Bernie Innocentif12d5bb2018-08-31 14:09:46 +090020 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;
Bernie Innocenti1f4a9fd2018-09-07 21:10:25 +090029};
Bernie Innocenti55864192018-08-30 04:05:20 +090030
Bernie Innocenti4acba1a2018-09-26 11:52:04 +090031res_static* res_get_static(void);
Bernie Innocenti55864192018-08-30 04:05:20 +090032
Bernie Innocentif89b3512018-08-30 07:34:37 +090033#endif // _RESOLV_STATIC_H_