diff options
Diffstat (limited to 'lib/lwres/getrrset.c')
-rw-r--r-- | lib/lwres/getrrset.c | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/lib/lwres/getrrset.c b/lib/lwres/getrrset.c index d8b6cc3..16af741 100644 --- a/lib/lwres/getrrset.c +++ b/lib/lwres/getrrset.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2012 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -21,12 +21,12 @@ /** * DESCRIPTION - * + * * lwres_getrrsetbyname() gets a set of resource records associated with * a hostname, class, and type. hostname is a pointer a to * null-terminated string. The flags field is currently unused and must * be zero. - * + * * After a successful call to lwres_getrrsetbyname(), *res is a pointer * to an #rrsetinfo structure, containing a list of one or more #rdatainfo * structures containing resource records and potentially another list of @@ -37,7 +37,7 @@ * in uncompressed DNS wire format. Properties of the rdataset are * represented in the #rri_flags bitfield. If the #RRSET_VALIDATED bit is * set, the data has been DNSSEC validated and the signatures verified. - * + * * All of the information returned by lwres_getrrsetbyname() is * dynamically allocated: the rrsetinfo and rdatainfo structures, and the * canonical host name strings pointed to by the rrsetinfostructure. @@ -45,15 +45,15 @@ * successful call to lwres_getrrsetbyname() is released by * lwres_freerrset(). rrset is a pointer to a struct rrset created by a * call to lwres_getrrsetbyname(). - * + * * The following structures are used: - * + * * \code * struct rdatainfo { * unsigned int rdi_length; // length of data * unsigned char *rdi_data; // record data * }; - * + * * struct rrsetinfo { * unsigned int rri_flags; // RRSET_VALIDATED... * unsigned int rri_rdclass; // class number @@ -66,23 +66,23 @@ * struct rdatainfo *rri_sigs; // individual signatures * }; * \endcode - * + * * \section getrrset_return Return Values - * + * * lwres_getrrsetbyname() returns zero on success, and one of the * following error codes if an error occurred: - * + * * \li #ERRSET_NONAME: the name does not exist - * + * * \li #ERRSET_NODATA: * the name exists, but does not have data of the desired type - * + * * \li #ERRSET_NOMEMORY: * memory could not be allocated - * + * * \li #ERRSET_INVAL: * a parameter is invalid - * + * * \li #ERRSET_FAIL: * other failure */ @@ -179,7 +179,7 @@ lwres_getrrsetbyname(const char *hostname, unsigned int rdclass, lwflags = 0; lwresult = lwres_getrdatabyname(lwrctx, hostname, - (lwres_uint16_t)rdclass, + (lwres_uint16_t)rdclass, (lwres_uint16_t)rdtype, lwflags, &response); if (lwresult != LWRES_R_SUCCESS) { @@ -271,18 +271,22 @@ lwres_getrrsetbyname(const char *hostname, unsigned int rdclass, void lwres_freerrset(struct rrsetinfo *rrset) { unsigned int i; - for (i = 0; i < rrset->rri_nrdatas; i++) { - if (rrset->rri_rdatas[i].rdi_data == NULL) - break; - free(rrset->rri_rdatas[i].rdi_data); + if (rrset->rri_rdatas != NULL) { + for (i = 0; i < rrset->rri_nrdatas; i++) { + if (rrset->rri_rdatas[i].rdi_data == NULL) + break; + free(rrset->rri_rdatas[i].rdi_data); + } + free(rrset->rri_rdatas); } - free(rrset->rri_rdatas); - for (i = 0; i < rrset->rri_nsigs; i++) { - if (rrset->rri_sigs[i].rdi_data == NULL) - break; - free(rrset->rri_sigs[i].rdi_data); + if (rrset->rri_sigs != NULL) { + for (i = 0; i < rrset->rri_nsigs; i++) { + if (rrset->rri_sigs[i].rdi_data == NULL) + break; + free(rrset->rri_sigs[i].rdi_data); + } + free(rrset->rri_sigs); } - free(rrset->rri_sigs); free(rrset->rri_name); free(rrset); } |