From: Shawn Routhier Date: Wed, 17 Mar 2010 17:07:43 +0000 (+0000) Subject: Modify the routine that constructs DNS names to convert relative names to X-Git-Tag: v4_2_0b1~3^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f4bc8261ca8cfc52d46d31132327a4876705e9f1;p=thirdparty%2Fdhcp.git Modify the routine that constructs DNS names to convert relative names to absolute names (add trailing dot) to keep the dns library happy. Ticket 21054 --- diff --git a/RELNOTES b/RELNOTES index 4a6fceea4..03e1f9f4b 100644 --- a/RELNOTES +++ b/RELNOTES @@ -39,12 +39,16 @@ The system has only been tested on Linux, FreeBSD, and Solaris, and may not work on other platforms. Please report any problems and suggested fixes to . - Changes since 4.2.0a2 - Update the fsync code to work with the changes to the DDNS code. It now uses a timer instead of noticing if there are no more packets to process. +- When constructing the DNS name structure from a text string append + the root to relative names. This satisfies a requirement in the DNS + library that names be absolute instead of relative and prevents DHCP + from crashing. Bug ticket 21054. + Changes since 4.2.0a1 - When using 'ignore client-updates;', the FQDN returned to the client diff --git a/omapip/isclib.c b/omapip/isclib.c index 3225096d2..f44f331b6 100644 --- a/omapip/isclib.c +++ b/omapip/isclib.c @@ -157,7 +157,15 @@ dhcp_context_create(void) { return(result); } -/* Convert a string name into the proper structure for the isc routines */ +/* + * Convert a string name into the proper structure for the isc routines + * + * Previously we allowed names without a trailing '.' however the current + * dns and dst code requires the names to end in a period. If the + * name doesn't have a trailing period add one as part of creating + * the dns name. + */ + isc_result_t dhcp_isc_name(unsigned char *namestr, dns_fixedname_t *namefix, @@ -166,13 +174,13 @@ dhcp_isc_name(unsigned char *namestr, size_t namelen; isc_buffer_t b; isc_result_t result; - + namelen = strlen((char *)namestr); isc_buffer_init(&b, namestr, namelen); isc_buffer_add(&b, namelen); dns_fixedname_init(namefix); *name = dns_fixedname_name(namefix); - result = dns_name_fromtext(*name, &b, NULL, 0, NULL); + result = dns_name_fromtext(*name, &b, dns_rootname, 0, NULL); isc_buffer_invalidate(&b); return(result); } @@ -188,7 +196,6 @@ isclib_make_dst_key(char *inname, dns_name_t *name; dns_fixedname_t name0; isc_buffer_t b; - int namelen; isc_buffer_init(&b, secret, length); isc_buffer_add(&b, length); @@ -198,29 +205,7 @@ isclib_make_dst_key(char *inname, return(DHCP_R_INVALIDARG); } - /* - * Previously we allowed key names without a trailing '.' - * however the current dst code requires the names to end - * in a period. If the name doesn't have a trailing period - * add one before sending it to the dst code. - */ - namelen = strlen(inname); - if (inname[namelen-1] != '.') { - char *newname = NULL; - newname = (char *)dmalloc(namelen + 2, MDL); - if (newname == NULL) { - log_error("unable to allocate memory for key name"); - return(ISC_R_NOMEMORY); - } - strcpy(newname, inname); - newname[namelen] = '.'; - newname[namelen+1] = 0; - result = dhcp_isc_name((unsigned char *)newname, &name0, &name); - dfree(newname, MDL); - } else { - result = dhcp_isc_name((unsigned char *)inname, &name0, &name); - } - + result = dhcp_isc_name((unsigned char *)inname, &name0, &name); if (result != ISC_R_SUCCESS) { return(result); }