]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
- Test for lease before dereferencing it in dhcprequest.
authorTed Lemon <source@isc.org>
Tue, 30 Mar 1999 20:40:59 +0000 (20:40 +0000)
committerTed Lemon <source@isc.org>
Tue, 30 Mar 1999 20:40:59 +0000 (20:40 +0000)
- Free the client parameter request list in dhcpnak if there is one.

server/dhcp.c

index 30a71be292598c42caa70948b8d2aab25bfec8e7..52164febb59419f9d234b29db77fdd8ab0f3daf2 100644 (file)
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: dhcp.c,v 1.57.2.23 1999/03/29 22:29:31 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhcp.c,v 1.57.2.24 1999/03/30 20:40:59 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -314,7 +314,8 @@ void dhcprequest (packet)
        }
 
        /* If we're not allowed to serve this client anymore, don't. */
-       if (!lease -> host &&
+       if (lease &&
+           !lease -> host &&
            !lease -> subnet -> group -> boot_unknown_clients) {
                note ("Ignoring unknown client %s",
                      print_hw_addr (packet -> raw -> htype,
@@ -449,6 +450,7 @@ void nak_lease (packet, cip)
        unsigned char nak = DHCPNAK;
        struct packet outgoing;
        struct hardware hto;
+       int i;
 
        struct tree_cache *options [256];
        struct tree_cache dhcpnak_tree;
@@ -476,9 +478,12 @@ void nak_lease (packet, cip)
        options [DHO_DHCP_MESSAGE] -> tree = (struct tree *)0;
 
        /* Do not use the client's requested parameter list. */
-       packet -> options [DHO_DHCP_PARAMETER_REQUEST_LIST].len = 0;
-       packet -> options [DHO_DHCP_PARAMETER_REQUEST_LIST].data =
-               (unsigned char *)0;
+       i = DHO_DHCP_PARAMETER_REQUEST_LIST;
+       if (packet -> options [i].data) {
+               packet -> options [i].len = 0;
+               dfree (packet -> options [i].data, "nak_lease");
+               packet -> options [i].data = (unsigned char *)0;
+       }
 
        /* Set up the option buffer... */
        outgoing.packet_length =