blob: 8d0618b5355edc5ec36357055afb4f049d976d43 [file] [log] [blame]
Bernie Innocentiac18b122018-10-01 23:10:18 +09001#ifndef NETD_RESOLV_STATIC_H
2#define NETD_RESOLV_STATIC_H
Bernie Innocenti318ed2d2018-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 Innocenti8ad893f2018-08-31 14:09:46 +090015#define MAXALIASES 35
16#define MAXADDRS 35
Bernie Innocenti318ed2d2018-08-30 04:05:20 +090017
Bernie Innocenti9c575932018-09-07 21:10:25 +090018struct res_static {
Bernie Innocenti8ad893f2018-08-31 14:09:46 +090019 char* h_addr_ptrs[MAXADDRS + 1];
20 char* host_aliases[MAXALIASES];
21 char hostbuf[8 * 1024];
chenbrucec51f1212019-09-12 16:59:33 +080022 uint32_t host_addr[16 / sizeof(uint32_t)]; /* IPv4 or IPv6 */
Bernie Innocenti8ad893f2018-08-31 14:09:46 +090023 FILE* hostf;
24 int stayopen;
25 const char* servent_ptr;
26 struct servent servent;
27 struct hostent host;
Bernie Innocenti9c575932018-09-07 21:10:25 +090028};
Bernie Innocenti318ed2d2018-08-30 04:05:20 +090029
Bernie Innocentiac18b122018-10-01 23:10:18 +090030res_static* res_get_static();
Bernie Innocenti318ed2d2018-08-30 04:05:20 +090031
Bernie Innocentiac18b122018-10-01 23:10:18 +090032#endif // NETD_RESOLV_STATIC_H