diff options
Diffstat (limited to 'openbsd-compat/getrrsetbyname.c')
-rw-r--r-- | openbsd-compat/getrrsetbyname.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/openbsd-compat/getrrsetbyname.c b/openbsd-compat/getrrsetbyname.c index bea6aea3b..07231d005 100644 --- a/openbsd-compat/getrrsetbyname.c +++ b/openbsd-compat/getrrsetbyname.c | |||
@@ -49,6 +49,12 @@ | |||
49 | 49 | ||
50 | #ifndef HAVE_GETRRSETBYNAME | 50 | #ifndef HAVE_GETRRSETBYNAME |
51 | 51 | ||
52 | #include <stdlib.h> | ||
53 | #include <string.h> | ||
54 | |||
55 | #include <netinet/in.h> | ||
56 | #include <arpa/inet.h> | ||
57 | |||
52 | #include "getrrsetbyname.h" | 58 | #include "getrrsetbyname.h" |
53 | 59 | ||
54 | #if defined(HAVE_DECL_H_ERRNO) && !HAVE_DECL_H_ERRNO | 60 | #if defined(HAVE_DECL_H_ERRNO) && !HAVE_DECL_H_ERRNO |
@@ -60,6 +66,13 @@ extern int h_errno; | |||
60 | # undef _THREAD_PRIVATE | 66 | # undef _THREAD_PRIVATE |
61 | #endif | 67 | #endif |
62 | #define _THREAD_PRIVATE(a,b,c) (c) | 68 | #define _THREAD_PRIVATE(a,b,c) (c) |
69 | |||
70 | /* to avoid conflicts where a platform already has _res */ | ||
71 | #ifdef _res | ||
72 | # undef _res | ||
73 | #endif | ||
74 | #define _res _compat_res | ||
75 | |||
63 | struct __res_state _res; | 76 | struct __res_state _res; |
64 | 77 | ||
65 | /* Necessary functions and macros */ | 78 | /* Necessary functions and macros */ |
@@ -290,10 +303,12 @@ getrrsetbyname(const char *hostname, unsigned int rdclass, | |||
290 | } | 303 | } |
291 | 304 | ||
292 | /* allocate memory for signatures */ | 305 | /* allocate memory for signatures */ |
293 | rrset->rri_sigs = calloc(rrset->rri_nsigs, sizeof(struct rdatainfo)); | 306 | if (rrset->rri_nsigs > 0) { |
294 | if (rrset->rri_sigs == NULL) { | 307 | rrset->rri_sigs = calloc(rrset->rri_nsigs, sizeof(struct rdatainfo)); |
295 | result = ERRSET_NOMEMORY; | 308 | if (rrset->rri_sigs == NULL) { |
296 | goto fail; | 309 | result = ERRSET_NOMEMORY; |
310 | goto fail; | ||
311 | } | ||
297 | } | 312 | } |
298 | 313 | ||
299 | /* copy answers & signatures */ | 314 | /* copy answers & signatures */ |