diff options
Diffstat (limited to 'contrib/isc-dhcp/client/dhclient.c')
-rw-r--r-- | contrib/isc-dhcp/client/dhclient.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/contrib/isc-dhcp/client/dhclient.c b/contrib/isc-dhcp/client/dhclient.c index 08fa4fc..d9a1b9f 100644 --- a/contrib/isc-dhcp/client/dhclient.c +++ b/contrib/isc-dhcp/client/dhclient.c @@ -56,7 +56,7 @@ #ifndef lint static char ocopyright[] = -"$Id: dhclient.c,v 1.44.2.14 1999/02/09 04:59:50 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dhclient.c,v 1.44.2.24 1999/02/27 21:51:35 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -92,7 +92,7 @@ int save_scripts; static char copyright[] = "Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium."; static char arr [] = "All rights reserved."; -static char message [] = "Internet Software Consortium DHCP Client V2.0b1pl11"; +static char message [] = "Internet Software Consortium DHCP Client V2.0b1pl17"; static char contrib [] = "\nPlease contribute if you find this software useful."; static char url [] = "For info, please visit http://www.isc.org/dhcp-contrib.html\n"; @@ -106,7 +106,7 @@ int main (argc, argv, envp) struct servent *ent; struct interface_info *ip; int seed; - int quiet; + int quiet = 0; #ifdef SYSLOG_4_2 openlog ("dhclient", LOG_NDELAY); @@ -498,6 +498,10 @@ void dhcpack (packet) ip -> client -> new -> expiry = getULong (ip -> client -> new -> options [DHO_DHCP_LEASE_TIME].data); + /* A number that looks negative here is really just very large, + because the lease expiry offset is unsigned. */ + if (ip -> client -> new -> expiry < 0) + ip -> client -> new -> expiry = TIME_MAX; /* Take the server-provided renewal time if there is one; otherwise figure it out according to the spec. */ @@ -521,8 +525,15 @@ void dhcpack (packet) ip -> client -> new -> renewal / 4; ip -> client -> new -> expiry += cur_time; + /* Lease lengths can never be negative. */ + if (ip -> client -> new -> expiry < cur_time) + ip -> client -> new -> expiry = TIME_MAX; ip -> client -> new -> renewal += cur_time; + if (ip -> client -> new -> renewal < cur_time) + ip -> client -> new -> renewal = TIME_MAX; ip -> client -> new -> rebind += cur_time; + if (ip -> client -> new -> rebind < cur_time) + ip -> client -> new -> rebind = TIME_MAX; bind_lease (ip); } @@ -1038,8 +1049,6 @@ void send_discover (ipp) ip -> client -> packet_length, inaddr_any, &sockaddr_broadcast, (struct hardware *)0); - if (result < 0) - warn ("send_packet: %m"); add_timeout (cur_time + ip -> client -> interval, send_discover, ip); } @@ -1292,9 +1301,6 @@ void send_request (ipp) from, &destination, (struct hardware *)0); - if (result < 0) - warn ("send_packet: %m"); - add_timeout (cur_time + ip -> client -> interval, send_request, ip); } @@ -1316,8 +1322,6 @@ void send_decline (ipp) ip -> client -> packet_length, inaddr_any, &sockaddr_broadcast, (struct hardware *)0); - if (result < 0) - warn ("send_packet: %m"); } void send_release (ipp) @@ -1337,8 +1341,6 @@ void send_release (ipp) ip -> client -> packet_length, inaddr_any, &sockaddr_broadcast, (struct hardware *)0); - if (result < 0) - warn ("send_packet: %m"); } void make_discover (ip, lease) @@ -1690,7 +1692,7 @@ void make_release (ip, lease) ip -> client -> packet.htype = ip -> hw_address.htype; ip -> client -> packet.hlen = ip -> hw_address.hlen; ip -> client -> packet.hops = 0; - ip -> client -> packet.xid = ip -> client -> xid; + ip -> client -> packet.xid = random (); ip -> client -> packet.secs = 0; ip -> client -> packet.flags = 0; memcpy (&ip -> client -> packet.ciaddr, @@ -2096,6 +2098,11 @@ void go_daemon () /* Become session leader and get pid... */ pid = setsid (); + /* Close standard I/O descriptors. */ + close(0); + close(1); + close(2); + write_client_pid_file (); } |