]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Several minor bugs never seen in any public release corrected.
authorDavid Hankins <dhankins@isc.org>
Wed, 2 Aug 2006 22:36:00 +0000 (22:36 +0000)
committerDavid Hankins <dhankins@isc.org>
Wed, 2 Aug 2006 22:36:00 +0000 (22:36 +0000)
[ISC-Bugs #16316]

common/conflex.c
common/options.c
server/ddns.c

index f91efc09e5fccd4ec9b457553b6c50ae7420ffa6..4b8d2358c154e23690fe1819a8f8934505223100 100644 (file)
@@ -34,7 +34,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: conflex.c,v 1.103 2006/07/31 22:19:51 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium.  All rights reserved.\n";
+"$Id: conflex.c,v 1.104 2006/08/02 22:36:00 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -1020,10 +1020,10 @@ static enum dhcp_token intern (atom, dfv)
              case 's':
                 if (!strcasecmp(atom + 1, "cript"))
                         return SCRIPT;
-               if (tolower(atom[1]) == 'e') {
+               if (isascii(atom[1]) && tolower(atom[1]) == 'e') {
                         if (!strcasecmp(atom + 2, "arch"))
                                 return SEARCH;
-                       if (tolower(atom[2]) == 'c') {
+                       if (isascii(atom[2]) && tolower(atom[2]) == 'c') {
                                if (!strcasecmp(atom + 3, "ond")) {
                                         if (!strcasecmp(atom + 6, "ary"))
                                                 return SECONDARY;
@@ -1067,14 +1067,14 @@ static enum dhcp_token intern (atom, dfv)
                                 return TOKEN_SET;
                        break;
                }
-               if (tolower(atom[1]) == 'h') {
+               if (isascii(atom[1]) && tolower(atom[1]) == 'h') {
                         if (!strcasecmp(atom + 2, "ared-network"))
                                 return SHARED_NETWORK;
                         if (!strcasecmp(atom + 2, "utdown"))
                                 return SHUTDOWN;
                        break;
                }
-               if (tolower(atom[1]) == 'i') {
+               if (isascii(atom[1]) && tolower(atom[1]) == 'i') {
                         if (!strcasecmp(atom + 2, "addr"))
                                 return SIADDR;
                         if (!strcasecmp(atom + 2, "gned"))
@@ -1083,8 +1083,8 @@ static enum dhcp_token intern (atom, dfv)
                                 return SIZE;
                        break;
                }
-               if (tolower(atom[1]) == 'p') {
-                       if (tolower(atom[2]) == 'a') {
+               if (isascii(atom[1]) && tolower(atom[1]) == 'p') {
+                       if (isascii(atom[2]) && tolower(atom[2]) == 'a') {
                                 if (!strcasecmp(atom + 3, "ce"))
                                         return SPACE;
                                 if (!strcasecmp(atom + 3, "wn"))
@@ -1095,16 +1095,17 @@ static enum dhcp_token intern (atom, dfv)
                                 return SPLIT;
                        break;
                }
-               if (tolower(atom[1]) == 't') {
-                       if (tolower(atom[2]) == 'a') {
-                               if(strncasecmp(atom + 3, "rt", 2)) {
+               if (isascii(atom[1]) && tolower(atom[1]) == 't') {
+                       if (isascii(atom[2]) && tolower(atom[2]) == 'a') {
+                               if(!strncasecmp(atom + 3, "rt", 2)) {
                                          if (!strcasecmp(atom + 5, "s"))
                                                  return STARTS;
                                          if (!strcasecmp(atom + 5, "up"))
                                                  return STARTUP;
                                        break;
                                }
-                               if (tolower(atom[3]) == 't') {
+                               if (isascii(atom[3]) &&
+                                   tolower(atom[3]) == 't') {
                                         if (!strcasecmp(atom + 4, "e"))
                                                 return STATE;
                                         if (!strcasecmp(atom + 4, "ic"))
@@ -1125,7 +1126,7 @@ static enum dhcp_token intern (atom, dfv)
                                 return SUBSTRING;
                         break;
                 }
-               if (tolower(atom[1]) == 'u') {
+               if (isascii(atom[1]) && tolower(atom[1]) == 'u') {
                         if (!strcasecmp(atom + 2, "ffix"))
                                 return SUFFIX;
                         if (!strcasecmp(atom + 2, "persede"))
index d2ef82c51cf833e71a2bb0ba31330329211b30e0..5060f0caef2aff504ac2d5113a6c8c9f4b5abe67 100644 (file)
@@ -34,7 +34,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: options.c,v 1.95 2006/07/31 22:19:51 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium.  All rights reserved.\n";
+"$Id: options.c,v 1.96 2006/08/02 22:36:00 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #define DHCP_OPTION_DATA
@@ -152,8 +152,8 @@ int parse_option_buffer (options, buffer, length, universe)
        memcpy (bp -> data, buffer, length);
 
        for (offset = 0;
-            (offset + universe->tag_size) > length &&
-            (code = universe->get_tag(bp->data + offset)) != universe->end; ) {
+            (offset + universe->tag_size) <= length &&
+            (code = universe->get_tag(buffer + offset)) != universe->end; ) {
                offset += universe->tag_size;
 
                /* Pad options don't have a length - just skip them. */
@@ -161,14 +161,15 @@ int parse_option_buffer (options, buffer, length, universe)
                        continue;
 
                /* Don't look for length if the buffer isn't that big. */
-               if (offset + universe->length_size > length) {
+               if ((offset + universe->length_size) > length) {
                        len = 65536;
                        goto bogus;
                }
 
-               /* All other fields (except end, see above) have a
-                  one-byte length. */
-               len = universe->get_length(bp->data + offset);
+               /* All other fields (except PAD and END handled above)
+                * have a length field.
+                */
+               len = universe->get_length(buffer + offset);
 
                offset += universe->length_size;
 
index 4e318def14c6108c25a70cfccd8dbb3dea89646e..6323056f099ed7f2c18029eeadf1a09436206bf1 100644 (file)
@@ -34,7 +34,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: ddns.c,v 1.22 2006/07/20 16:27:45 shane Exp $ Copyright (c) 2004-2005 Internet Systems Consortium.  All rights reserved.\n";
+"$Id: ddns.c,v 1.23 2006/08/02 22:36:00 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -241,6 +241,7 @@ int ddns_updates (struct packet *packet,
        if (lease -> ip_addr . len != 4)
                return 0;
 
+       memset(&d1, 0, sizeof(d1));
        memset (&ddns_hostname, 0, sizeof (ddns_hostname));
        memset (&ddns_domainname, 0, sizeof (ddns_domainname));
        memset (&old_ddns_fwd_name, 0, sizeof (ddns_fwd_name));
@@ -455,7 +456,6 @@ int ddns_updates (struct packet *packet,
         * Compute the RR TTL.
         */
        ddns_ttl = DEFAULT_DDNS_TTL;
-       memset (&d1, 0, sizeof d1);
        if ((oc = lookup_option (&server_universe, state -> options,
                                 SV_DDNS_TTL))) {
                if (evaluate_option_cache (&d1, packet, lease,