2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-09-01 06:45:27 +00:00

Several minor bugs never seen in any public release corrected.

[ISC-Bugs #16316]
This commit is contained in:
David Hankins
2006-08-02 22:36:00 +00:00
parent 663e6621c7
commit 5786874726
3 changed files with 23 additions and 21 deletions

View File

@@ -34,7 +34,7 @@
#ifndef lint #ifndef lint
static char copyright[] = 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 */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@@ -1020,10 +1020,10 @@ static enum dhcp_token intern (atom, dfv)
case 's': case 's':
if (!strcasecmp(atom + 1, "cript")) if (!strcasecmp(atom + 1, "cript"))
return SCRIPT; return SCRIPT;
if (tolower(atom[1]) == 'e') { if (isascii(atom[1]) && tolower(atom[1]) == 'e') {
if (!strcasecmp(atom + 2, "arch")) if (!strcasecmp(atom + 2, "arch"))
return SEARCH; return SEARCH;
if (tolower(atom[2]) == 'c') { if (isascii(atom[2]) && tolower(atom[2]) == 'c') {
if (!strcasecmp(atom + 3, "ond")) { if (!strcasecmp(atom + 3, "ond")) {
if (!strcasecmp(atom + 6, "ary")) if (!strcasecmp(atom + 6, "ary"))
return SECONDARY; return SECONDARY;
@@ -1067,14 +1067,14 @@ static enum dhcp_token intern (atom, dfv)
return TOKEN_SET; return TOKEN_SET;
break; break;
} }
if (tolower(atom[1]) == 'h') { if (isascii(atom[1]) && tolower(atom[1]) == 'h') {
if (!strcasecmp(atom + 2, "ared-network")) if (!strcasecmp(atom + 2, "ared-network"))
return SHARED_NETWORK; return SHARED_NETWORK;
if (!strcasecmp(atom + 2, "utdown")) if (!strcasecmp(atom + 2, "utdown"))
return SHUTDOWN; return SHUTDOWN;
break; break;
} }
if (tolower(atom[1]) == 'i') { if (isascii(atom[1]) && tolower(atom[1]) == 'i') {
if (!strcasecmp(atom + 2, "addr")) if (!strcasecmp(atom + 2, "addr"))
return SIADDR; return SIADDR;
if (!strcasecmp(atom + 2, "gned")) if (!strcasecmp(atom + 2, "gned"))
@@ -1083,8 +1083,8 @@ static enum dhcp_token intern (atom, dfv)
return SIZE; return SIZE;
break; break;
} }
if (tolower(atom[1]) == 'p') { if (isascii(atom[1]) && tolower(atom[1]) == 'p') {
if (tolower(atom[2]) == 'a') { if (isascii(atom[2]) && tolower(atom[2]) == 'a') {
if (!strcasecmp(atom + 3, "ce")) if (!strcasecmp(atom + 3, "ce"))
return SPACE; return SPACE;
if (!strcasecmp(atom + 3, "wn")) if (!strcasecmp(atom + 3, "wn"))
@@ -1095,16 +1095,17 @@ static enum dhcp_token intern (atom, dfv)
return SPLIT; return SPLIT;
break; break;
} }
if (tolower(atom[1]) == 't') { if (isascii(atom[1]) && tolower(atom[1]) == 't') {
if (tolower(atom[2]) == 'a') { if (isascii(atom[2]) && tolower(atom[2]) == 'a') {
if(strncasecmp(atom + 3, "rt", 2)) { if(!strncasecmp(atom + 3, "rt", 2)) {
if (!strcasecmp(atom + 5, "s")) if (!strcasecmp(atom + 5, "s"))
return STARTS; return STARTS;
if (!strcasecmp(atom + 5, "up")) if (!strcasecmp(atom + 5, "up"))
return STARTUP; return STARTUP;
break; break;
} }
if (tolower(atom[3]) == 't') { if (isascii(atom[3]) &&
tolower(atom[3]) == 't') {
if (!strcasecmp(atom + 4, "e")) if (!strcasecmp(atom + 4, "e"))
return STATE; return STATE;
if (!strcasecmp(atom + 4, "ic")) if (!strcasecmp(atom + 4, "ic"))
@@ -1125,7 +1126,7 @@ static enum dhcp_token intern (atom, dfv)
return SUBSTRING; return SUBSTRING;
break; break;
} }
if (tolower(atom[1]) == 'u') { if (isascii(atom[1]) && tolower(atom[1]) == 'u') {
if (!strcasecmp(atom + 2, "ffix")) if (!strcasecmp(atom + 2, "ffix"))
return SUFFIX; return SUFFIX;
if (!strcasecmp(atom + 2, "persede")) if (!strcasecmp(atom + 2, "persede"))

View File

@@ -34,7 +34,7 @@
#ifndef lint #ifndef lint
static char copyright[] = 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 */ #endif /* not lint */
#define DHCP_OPTION_DATA #define DHCP_OPTION_DATA
@@ -152,8 +152,8 @@ int parse_option_buffer (options, buffer, length, universe)
memcpy (bp -> data, buffer, length); memcpy (bp -> data, buffer, length);
for (offset = 0; for (offset = 0;
(offset + universe->tag_size) > length && (offset + universe->tag_size) <= length &&
(code = universe->get_tag(bp->data + offset)) != universe->end; ) { (code = universe->get_tag(buffer + offset)) != universe->end; ) {
offset += universe->tag_size; offset += universe->tag_size;
/* Pad options don't have a length - just skip them. */ /* Pad options don't have a length - just skip them. */
@@ -161,14 +161,15 @@ int parse_option_buffer (options, buffer, length, universe)
continue; continue;
/* Don't look for length if the buffer isn't that big. */ /* 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; len = 65536;
goto bogus; goto bogus;
} }
/* All other fields (except end, see above) have a /* All other fields (except PAD and END handled above)
one-byte length. */ * have a length field.
len = universe->get_length(bp->data + offset); */
len = universe->get_length(buffer + offset);
offset += universe->length_size; offset += universe->length_size;

View File

@@ -34,7 +34,7 @@
#ifndef lint #ifndef lint
static char copyright[] = 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 */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@@ -241,6 +241,7 @@ int ddns_updates (struct packet *packet,
if (lease -> ip_addr . len != 4) if (lease -> ip_addr . len != 4)
return 0; return 0;
memset(&d1, 0, sizeof(d1));
memset (&ddns_hostname, 0, sizeof (ddns_hostname)); memset (&ddns_hostname, 0, sizeof (ddns_hostname));
memset (&ddns_domainname, 0, sizeof (ddns_domainname)); memset (&ddns_domainname, 0, sizeof (ddns_domainname));
memset (&old_ddns_fwd_name, 0, sizeof (ddns_fwd_name)); memset (&old_ddns_fwd_name, 0, sizeof (ddns_fwd_name));
@@ -455,7 +456,6 @@ int ddns_updates (struct packet *packet,
* Compute the RR TTL. * Compute the RR TTL.
*/ */
ddns_ttl = DEFAULT_DDNS_TTL; ddns_ttl = DEFAULT_DDNS_TTL;
memset (&d1, 0, sizeof d1);
if ((oc = lookup_option (&server_universe, state -> options, if ((oc = lookup_option (&server_universe, state -> options,
SV_DDNS_TTL))) { SV_DDNS_TTL))) {
if (evaluate_option_cache (&d1, packet, lease, if (evaluate_option_cache (&d1, packet, lease,