From: David Hankins Date: Wed, 2 Aug 2006 22:36:00 +0000 (+0000) Subject: Several minor bugs never seen in any public release corrected. X-Git-Tag: v3_1_0a1~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5786874726d50723f1b78412434ec33295ceb64d;p=thirdparty%2Fdhcp.git Several minor bugs never seen in any public release corrected. [ISC-Bugs #16316] --- diff --git a/common/conflex.c b/common/conflex.c index f91efc09e..4b8d2358c 100644 --- a/common/conflex.c +++ b/common/conflex.c @@ -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")) diff --git a/common/options.c b/common/options.c index d2ef82c51..5060f0cae 100644 --- a/common/options.c +++ b/common/options.c @@ -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; diff --git a/server/ddns.c b/server/ddns.c index 4e318def1..6323056f0 100644 --- a/server/ddns.c +++ b/server/ddns.c @@ -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,