Bernie Innocenti | ac18b12 | 2018-10-01 23:10:18 +0900 | [diff] [blame] | 1 | #ifndef NETD_RESOLV_STATIC_H |
| 2 | #define NETD_RESOLV_STATIC_H |
Bernie Innocenti | 318ed2d | 2018-08-30 04:05:20 +0900 | [diff] [blame] | 3 | |
| 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 Innocenti | 8ad893f | 2018-08-31 14:09:46 +0900 | [diff] [blame] | 15 | #define MAXALIASES 35 |
| 16 | #define MAXADDRS 35 |
Bernie Innocenti | 318ed2d | 2018-08-30 04:05:20 +0900 | [diff] [blame] | 17 | |
Bernie Innocenti | 9c57593 | 2018-09-07 21:10:25 +0900 | [diff] [blame] | 18 | struct res_static { |
Bernie Innocenti | 8ad893f | 2018-08-31 14:09:46 +0900 | [diff] [blame] | 19 | char* h_addr_ptrs[MAXADDRS + 1]; |
| 20 | char* host_aliases[MAXALIASES]; |
| 21 | char hostbuf[8 * 1024]; |
chenbruce | c51f121 | 2019-09-12 16:59:33 +0800 | [diff] [blame] | 22 | uint32_t host_addr[16 / sizeof(uint32_t)]; /* IPv4 or IPv6 */ |
Bernie Innocenti | 8ad893f | 2018-08-31 14:09:46 +0900 | [diff] [blame] | 23 | FILE* hostf; |
| 24 | int stayopen; |
| 25 | const char* servent_ptr; |
| 26 | struct servent servent; |
| 27 | struct hostent host; |
Bernie Innocenti | 9c57593 | 2018-09-07 21:10:25 +0900 | [diff] [blame] | 28 | }; |
Bernie Innocenti | 318ed2d | 2018-08-30 04:05:20 +0900 | [diff] [blame] | 29 | |
Bernie Innocenti | ac18b12 | 2018-10-01 23:10:18 +0900 | [diff] [blame] | 30 | res_static* res_get_static(); |
Bernie Innocenti | 318ed2d | 2018-08-30 04:05:20 +0900 | [diff] [blame] | 31 | |
Bernie Innocenti | ac18b12 | 2018-10-01 23:10:18 +0900 | [diff] [blame] | 32 | #endif // NETD_RESOLV_STATIC_H |