diff options
author | David Hankins <dhankins@isc.org> | 2005-10-10 16:45:39 +0000 |
---|---|---|
committer | David Hankins <dhankins@isc.org> | 2005-10-10 16:45:39 +0000 |
commit | b9409d85ac065e88d626225e120a0c3d267edb8c (patch) | |
tree | 97322060fbfcbe75fc1c2a13c00e64f954ae703f | |
parent | cd212e28a602e1266417d8f55075acd925080907 (diff) | |
download | isc-dhcp-b9409d85ac065e88d626225e120a0c3d267edb8c.tar.gz |
- Several minor bugs, largely relating to treating 8-byte time values as
4-byte entities, have been repaired after careful review of the FreeBSD
ports collection's patch set. Thanks to the nameless entities who have
contributed to the FreeBSD ports. [ISC-bugs #13722]
-rw-r--r-- | RELNOTES | 5 | ||||
-rw-r--r-- | client/clparse.c | 13 | ||||
-rw-r--r-- | client/dhclient.c | 39 | ||||
-rw-r--r-- | common/conflex.c | 4 | ||||
-rw-r--r-- | common/dispatch.c | 4 | ||||
-rw-r--r-- | common/parse.c | 7 | ||||
-rw-r--r-- | includes/dhcpd.h | 4 | ||||
-rw-r--r-- | includes/omapip/trace.h | 4 | ||||
-rw-r--r-- | omapip/trace.c | 6 |
9 files changed, 46 insertions, 40 deletions
@@ -105,6 +105,11 @@ and for prodding me into improving it. - An OMAPI host/network byte order problem in lease time values has been repaired. +- Several minor bugs, largely relating to treating 8-byte time values as + 4-byte entities, have been repaired after careful review of the FreeBSD + ports collection's patch set. Thanks to the nameless entities who have + contributed to the FreeBSD ports. + Changes since 3.0.3b3 - dhclient.conf documentation for interface {} was updated to reflect recent diff --git a/client/clparse.c b/client/clparse.c index 98744e31..40363a14 100644 --- a/client/clparse.c +++ b/client/clparse.c @@ -34,7 +34,7 @@ #ifndef lint static char copyright[] = -"$Id: clparse.c,v 1.62.2.8 2005/08/26 22:45:43 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium. All rights reserved.\n"; +"$Id: clparse.c,v 1.62.2.9 2005/10/10 16:45:38 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -772,7 +772,13 @@ int interface_or_dummy (struct interface_info **pi, const char *name) if ((status = interface_allocate (&ip, MDL)) != ISC_R_SUCCESS) log_fatal ("Can't record interface %s: %s", name, isc_result_totext (status)); - strcpy (ip -> name, name); + + if (strlen(name) >= sizeof(ip->name)) { + interface_dereference(&ip, MDL); + return 0; + } + strcpy(ip->name, name); + if (dummy_interfaces) { interface_reference (&ip -> next, dummy_interfaces, MDL); @@ -990,7 +996,8 @@ void parse_client_lease_declaration (cfile, lease, ipp, clientp) skip_to_semi (cfile); break; } - interface_or_dummy (ipp, val); + if (!interface_or_dummy (ipp, val)) + log_fatal ("Can't allocate interface %s.", val); break; case NAME: diff --git a/client/dhclient.c b/client/dhclient.c index dcf65b56..54bfc15b 100644 --- a/client/dhclient.c +++ b/client/dhclient.c @@ -32,7 +32,7 @@ #ifndef lint static char ocopyright[] = -"$Id: dhclient.c,v 1.129.2.28 2005/08/26 22:45:43 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium. All rights reserved.\n"; +"$Id: dhclient.c,v 1.129.2.29 2005/10/10 16:45:38 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -212,10 +212,10 @@ int main (argc, argv, envp) if (status != ISC_R_SUCCESS) log_fatal ("Can't record interface %s:%s", argv [i], isc_result_totext (status)); - if (strlen (argv [i]) > sizeof tmp -> name) - log_fatal ("%s: interface name too long (max %ld)", - argv [i], (long)strlen (argv [i])); - strcpy (tmp -> name, argv [i]); + if (strlen(argv[i]) >= sizeof(tmp->name)) + log_fatal("%s: interface name too long (is %ld)", + argv [i], (long)strlen(argv[i])); + strcpy(tmp->name, argv[i]); if (interfaces) { interface_reference (&tmp -> next, interfaces, MDL); @@ -789,11 +789,9 @@ void dhcpack (packet) client -> new -> renewal = TIME_MAX; /* Now introduce some randomness to the renewal time: */ - if (client -> new -> renewal <= TIME_MAX / 3 - 3) - client -> new -> renewal = - (((client -> new -> renewal + 3) * 3 / 4) + - (random () % /* XXX NUMS */ - ((client -> new -> renewal + 3) / 4))); + if (client->new->renewal <= ((TIME_MAX / 3) - 3)) + client->new->renewal = (((client->new->renewal * 3) + 3) / 4) + + (((random() % client->new->renewal) + 3) / 4); /* Same deal with the rebind time. */ oc = lookup_option (&dhcp_universe, client -> new -> options, @@ -1400,22 +1398,17 @@ void send_discover (cpp) between zero and two times itself. On average, this means that it will double with every transmission. */ if (increase) { - if (!client -> interval) - client -> interval = - client -> config -> initial_interval; + if (!client->interval) + client->interval = client->config->initial_interval; else - client -> interval += ((random () >> 2) % - (2 * client -> interval)); + client->interval += random() % (2 * client->interval); /* Don't backoff past cutoff. */ - if (client -> interval > - client -> config -> backoff_cutoff) - client -> interval = - ((client -> config -> backoff_cutoff / 2) - + ((random () >> 2) % - client -> config -> backoff_cutoff)); - } else if (!client -> interval) - client -> interval = client -> config -> initial_interval; + if (client->interval > client->config->backoff_cutoff) + client->interval = (client->config->backoff_cutoff / 2) + + (random() % client->config->backoff_cutoff); + } else if (!client->interval) + client->interval = client->config->initial_interval; /* If the backoff would take us to the panic timeout, just use that as the interval. */ diff --git a/common/conflex.c b/common/conflex.c index c740b2d6..7cae3e0a 100644 --- a/common/conflex.c +++ b/common/conflex.c @@ -34,7 +34,7 @@ #ifndef lint static char copyright[] = -"$Id: conflex.c,v 1.92.2.15 2005/09/22 16:19:56 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium. All rights reserved.\n"; +"$Id: conflex.c,v 1.92.2.16 2005/10/10 16:45:39 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -458,7 +458,7 @@ static enum dhcp_token read_number (c, cfile) log_fatal("read_number():%s:%d: impossible case", MDL); } #else /* OLD_LEXER */ - if (!seenx && (c == 'x') { + if (!seenx && (c == 'x')) { seenx = 1; } else if (!isascii (c) || !isxdigit (c)) { if (c != EOF) { diff --git a/common/dispatch.c b/common/dispatch.c index 5b6c19ae..9addda48 100644 --- a/common/dispatch.c +++ b/common/dispatch.c @@ -34,7 +34,7 @@ #ifndef lint static char copyright[] = -"$Id: dispatch.c,v 1.63.2.5 2005/08/26 22:45:45 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium. All rights reserved.\n"; +"$Id: dispatch.c,v 1.63.2.6 2005/10/10 16:45:39 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -42,7 +42,7 @@ static char copyright[] = struct timeout *timeouts; static struct timeout *free_timeouts; -void set_time (u_int32_t t) +void set_time(TIME t) { /* Do any outstanding timeouts. */ if (cur_time != t) { diff --git a/common/parse.c b/common/parse.c index 64537c39..1a42cbcf 100644 --- a/common/parse.c +++ b/common/parse.c @@ -34,7 +34,7 @@ #ifndef lint static char copyright[] = -"$Id: parse.c,v 1.104.2.24 2005/08/26 22:45:46 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium. All rights reserved.\n"; +"$Id: parse.c,v 1.104.2.25 2005/10/10 16:45:39 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -405,6 +405,7 @@ void parse_lease_time (cfile, timep) { const char *val; enum dhcp_token token; + u_int32_t num; token = next_token (&val, (unsigned *)0, cfile); if (token != NUMBER) { @@ -412,9 +413,9 @@ void parse_lease_time (cfile, timep) skip_to_semi (cfile); return; } - convert_num (cfile, (unsigned char *)timep, val, 10, 32); + convert_num(cfile, (unsigned char *)&num, val, 10, 32); /* Unswap the number - convert_num returns stuff in NBO. */ - *timep = ntohl (*timep); /* XXX */ + *timep = ntohl(num); parse_semi (cfile); } diff --git a/includes/dhcpd.h b/includes/dhcpd.h index 6efa3d4d..b0fa9419 100644 --- a/includes/dhcpd.h +++ b/includes/dhcpd.h @@ -336,7 +336,7 @@ struct lease_state { struct option_state *options; struct data_string parameter_request_list; int max_message_size; - u_int32_t expiry, renewal, rebind; + TIME expiry, renewal, rebind; struct data_string filename, server_name; int got_requested_address; int got_server_identifier; @@ -1760,7 +1760,7 @@ int if_readsocket PROTO ((omapi_object_t *)); void reinitialize_interfaces PROTO ((void)); /* dispatch.c */ -void set_time (u_int32_t); +void set_time(TIME); struct timeval *process_outstanding_timeouts (struct timeval *); void dispatch PROTO ((void)); isc_result_t got_one PROTO ((omapi_object_t *)); diff --git a/includes/omapip/trace.h b/includes/omapip/trace.h index d48c3700..028798f8 100644 --- a/includes/omapip/trace.h +++ b/includes/omapip/trace.h @@ -3,7 +3,7 @@ Definitions for omapi tracing facility... */ /* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 2004-2005 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 2001-2003 by Internet Software Consortium * * Permission to use, copy, modify, and distribute this software for any @@ -90,7 +90,7 @@ typedef struct { void trace_free_all (void); int trace_playback (void); int trace_record (void); -isc_result_t trace_init (void (*set_time) (u_int32_t), const char *, int); +isc_result_t trace_init (void (*set_time) (TIME), const char *, int); isc_result_t trace_begin (const char *, const char *, int); isc_result_t trace_write_packet (trace_type_t *, unsigned, const char *, const char *, int); diff --git a/omapip/trace.c b/omapip/trace.c index 4ccba81e..39b428e6 100644 --- a/omapip/trace.c +++ b/omapip/trace.c @@ -34,13 +34,13 @@ #ifndef lint static char ocopyright[] = -"$Id: trace.c,v 1.9.2.4 2005/08/26 22:45:48 dhankins Exp $ Copyright 2004-2005 Internet Systems Consortium."; +"$Id: trace.c,v 1.9.2.5 2005/10/10 16:45:39 dhankins Exp $ Copyright 2004-2005 Internet Systems Consortium."; #endif #include <omapip/omapip_p.h> #if defined (TRACING) -void (*trace_set_time_hook) (u_int32_t); +void (*trace_set_time_hook) (TIME); static int tracing_stopped; static int traceoutfile; static int traceindex; @@ -102,7 +102,7 @@ int trace_record () return 0; } -isc_result_t trace_init (void (*set_time) (u_int32_t), +isc_result_t trace_init (void (*set_time) (TIME), const char *file, int line) { trace_type_t *root_type; |