]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Modify the routine that constructs DNS names to convert relative names to
authorShawn Routhier <sar@isc.org>
Wed, 17 Mar 2010 17:07:43 +0000 (17:07 +0000)
committerShawn Routhier <sar@isc.org>
Wed, 17 Mar 2010 17:07:43 +0000 (17:07 +0000)
absolute names (add trailing dot) to keep the dns library happy.  Ticket 21054

RELNOTES
omapip/isclib.c

index 4a6fceea478305dad36477f317d584b930ff5092..03e1f9f4b59e9b6e56768061acba26baa3fc3706 100644 (file)
--- 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
 <dhcp-users@isc.org>.
 
-
                        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
index 3225096d27fd658644e6a9e9affa667c2f63ed46..f44f331b6e83c89d2a1d6d3c4a38afe34f56272b 100644 (file)
@@ -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);
        }