diff options
| author | marc <> | 2003-01-28 04:58:00 +0000 |
|---|---|---|
| committer | marc <> | 2003-01-28 04:58:00 +0000 |
| commit | 547ebab319b228b064cf5dcb3ff0ae1bf23d24a2 (patch) | |
| tree | f57454716593fb3b68672505c6dccab6438498f1 /src/lib/libc/net/getrrsetbyname.c | |
| parent | 98a78d57b176408b5aca87705f9681c5b155b47c (diff) | |
| download | openbsd-547ebab319b228b064cf5dcb3ff0ae1bf23d24a2.tar.gz openbsd-547ebab319b228b064cf5dcb3ff0ae1bf23d24a2.tar.bz2 openbsd-547ebab319b228b064cf5dcb3ff0ae1bf23d24a2.zip | |
thread safer libc (note: safer, not safe)
Access to the global _res structure replaced by pointers to a
per thread instance. If unthreaded the pointer is to the
global structure.
Also replaced a 64k stack array with malloc-ed memory so
threaded aps (with a default 64k stack) have a chance at working.
ok deraadt@
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libc/net/getrrsetbyname.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lib/libc/net/getrrsetbyname.c b/src/lib/libc/net/getrrsetbyname.c index 1ec60486b3..e4bd9a936e 100644 --- a/src/lib/libc/net/getrrsetbyname.c +++ b/src/lib/libc/net/getrrsetbyname.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: getrrsetbyname.c,v 1.5 2002/09/07 20:54:04 jakob Exp $ */ | 1 | /* $OpenBSD: getrrsetbyname.c,v 1.6 2003/01/28 04:58:00 marc Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2001 Jakob Schlyter. All rights reserved. | 4 | * Copyright (c) 2001 Jakob Schlyter. All rights reserved. |
| @@ -51,6 +51,8 @@ | |||
| 51 | #include <stdlib.h> | 51 | #include <stdlib.h> |
| 52 | #include <string.h> | 52 | #include <string.h> |
| 53 | 53 | ||
| 54 | #include "thread_private.h" | ||
| 55 | |||
| 54 | #define ANSWER_BUFFER_SIZE 1024*64 | 56 | #define ANSWER_BUFFER_SIZE 1024*64 |
| 55 | 57 | ||
| 56 | struct dns_query { | 58 | struct dns_query { |
| @@ -95,6 +97,7 @@ getrrsetbyname(const char *hostname, unsigned int rdclass, | |||
| 95 | unsigned int rdtype, unsigned int flags, | 97 | unsigned int rdtype, unsigned int flags, |
| 96 | struct rrsetinfo **res) | 98 | struct rrsetinfo **res) |
| 97 | { | 99 | { |
| 100 | struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); | ||
| 98 | int result; | 101 | int result; |
| 99 | struct rrsetinfo *rrset = NULL; | 102 | struct rrsetinfo *rrset = NULL; |
| 100 | struct dns_response *response; | 103 | struct dns_response *response; |
| @@ -122,19 +125,19 @@ getrrsetbyname(const char *hostname, unsigned int rdclass, | |||
| 122 | } | 125 | } |
| 123 | 126 | ||
| 124 | /* initialize resolver */ | 127 | /* initialize resolver */ |
| 125 | if ((_res.options & RES_INIT) == 0 && res_init() == -1) { | 128 | if ((_resp->options & RES_INIT) == 0 && res_init() == -1) { |
| 126 | result = ERRSET_FAIL; | 129 | result = ERRSET_FAIL; |
| 127 | goto fail; | 130 | goto fail; |
| 128 | } | 131 | } |
| 129 | 132 | ||
| 130 | #ifdef DEBUG | 133 | #ifdef DEBUG |
| 131 | _res.options |= RES_DEBUG; | 134 | _resp->options |= RES_DEBUG; |
| 132 | #endif /* DEBUG */ | 135 | #endif /* DEBUG */ |
| 133 | 136 | ||
| 134 | #ifdef RES_USE_DNSSEC | 137 | #ifdef RES_USE_DNSSEC |
| 135 | /* turn on DNSSEC if EDNS0 is configured */ | 138 | /* turn on DNSSEC if EDNS0 is configured */ |
| 136 | if (_res.options & RES_USE_EDNS0) | 139 | if (_resp->options & RES_USE_EDNS0) |
| 137 | _res.options |= RES_USE_DNSSEC; | 140 | _resp->options |= RES_USE_DNSSEC; |
| 138 | #endif /* RES_USE_DNSEC */ | 141 | #endif /* RES_USE_DNSEC */ |
| 139 | 142 | ||
| 140 | /* make query */ | 143 | /* make query */ |
