]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
- Compute max-lease-time outside of conditional so that we always have
authorTed Lemon <source@isc.org>
Tue, 6 Jul 1999 20:35:54 +0000 (20:35 +0000)
committerTed Lemon <source@isc.org>
Tue, 6 Jul 1999 20:35:54 +0000 (20:35 +0000)
  a value for it.

server/dhcp.c

index 4108c8d11b217366667c60435fdb164713203b63..35625f0cbc3ac45ac26ead83dc8998ac52c74c34 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: dhcp.c,v 1.99 1999/07/06 17:09:03 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhcp.c,v 1.100 1999/07/06 20:35:54 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -1122,26 +1122,29 @@ void ack_lease (packet, lease, offer, when, msg)
                if (s1 && d1.len == sizeof (u_int32_t)) {
                        lease_time = getULong (d1.data);
                        data_string_forget (&d1, "ack_lease");
-                       max_lease_time = DEFAULT_MAX_LEASE_TIME;
-                       if ((oc = lookup_option (&server_universe,
-                                                state -> options,
-                                                SV_MAX_LEASE_TIME))) {
-                               if (evaluate_option_cache (&d1, packet,
-                                                          packet -> options,
-                                                          lease, oc)) {
-                                       if (d1.len == sizeof (u_int32_t))
-                                               max_lease_time =
-                                                       getULong (d1.data);
-                                       data_string_forget (&d1, "ack_lease");
-                               }
-                       }
                } else {
+                       if (s1)
+                               data_string_forget (&d1, "ack_lease");
                        lease_time = default_lease_time;
                }
                
+               /* See if there's a maximum lease time. */
+               max_lease_time = DEFAULT_MAX_LEASE_TIME;
+               if ((oc = lookup_option (&server_universe, state -> options,
+                                        SV_MAX_LEASE_TIME))) {
+                       if (evaluate_option_cache (&d1, packet,
+                                                  packet -> options,
+                                                  lease, oc)) {
+                               if (d1.len == sizeof (u_int32_t))
+                                       max_lease_time =
+                                               getULong (d1.data);
+                               data_string_forget (&d1, "ack_lease");
+                       }
+               }
+
                /* Enforce the maximum lease length. */
-               if (lease_time < 0 || /* XXX */
-                   lease_time > max_lease_time)
+               if (lease_time < 0 /* XXX */
+                   || lease_time > max_lease_time)
                        lease_time = max_lease_time;
                        
                min_lease_time = DEFAULT_MIN_LEASE_TIME;