X-Git-Url: http://andersk.mit.edu/gitweb/openssh.git/blobdiff_plain/4162eae560c6eb9f3676ee535d71ce6651d3e8b0..d0f02ff0a897bf1f33b940cf872745296ed29c24:/openbsd-compat/getrrsetbyname.c diff --git a/openbsd-compat/getrrsetbyname.c b/openbsd-compat/getrrsetbyname.c index bea6aea3..785b2256 100644 --- a/openbsd-compat/getrrsetbyname.c +++ b/openbsd-compat/getrrsetbyname.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getrrsetbyname.c,v 1.10 2005/03/30 02:58:28 tedu Exp $ */ +/* $OpenBSD: getrrsetbyname.c,v 1.11 2007/10/11 18:36:41 jakob Exp $ */ /* * Copyright (c) 2001 Jakob Schlyter. All rights reserved. @@ -49,6 +49,12 @@ #ifndef HAVE_GETRRSETBYNAME +#include +#include + +#include +#include + #include "getrrsetbyname.h" #if defined(HAVE_DECL_H_ERRNO) && !HAVE_DECL_H_ERRNO @@ -60,7 +66,10 @@ extern int h_errno; # undef _THREAD_PRIVATE #endif #define _THREAD_PRIVATE(a,b,c) (c) + +#ifndef HAVE__RES_EXTERN struct __res_state _res; +#endif /* Necessary functions and macros */ @@ -279,7 +288,7 @@ getrrsetbyname(const char *hostname, unsigned int rdclass, rrset->rri_nrdatas = count_dns_rr(response->answer, rrset->rri_rdclass, rrset->rri_rdtype); rrset->rri_nsigs = count_dns_rr(response->answer, rrset->rri_rdclass, - T_SIG); + T_RRSIG); /* allocate memory for answers */ rrset->rri_rdatas = calloc(rrset->rri_nrdatas, @@ -290,10 +299,12 @@ getrrsetbyname(const char *hostname, unsigned int rdclass, } /* allocate memory for signatures */ - rrset->rri_sigs = calloc(rrset->rri_nsigs, sizeof(struct rdatainfo)); - if (rrset->rri_sigs == NULL) { - result = ERRSET_NOMEMORY; - goto fail; + if (rrset->rri_nsigs > 0) { + rrset->rri_sigs = calloc(rrset->rri_nsigs, sizeof(struct rdatainfo)); + if (rrset->rri_sigs == NULL) { + result = ERRSET_NOMEMORY; + goto fail; + } } /* copy answers & signatures */ @@ -307,7 +318,7 @@ getrrsetbyname(const char *hostname, unsigned int rdclass, rdata = &rrset->rri_rdatas[index_ans++]; if (rr->class == rrset->rri_rdclass && - rr->type == T_SIG) + rr->type == T_RRSIG) rdata = &rrset->rri_sigs[index_sig++]; if (rdata) {