]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
- In order to satisfy the HP C compiler, make a (possibly malloc'd) copy
authorTed Lemon <source@isc.org>
Mon, 31 Jan 2000 23:43:11 +0000 (23:43 +0000)
committerTed Lemon <source@isc.org>
Mon, 31 Jan 2000 23:43:11 +0000 (23:43 +0000)
  of the host UID when mocking up a lease.

server/dhcp.c

index 0c6f1a0b5270dbf31e49ca13950349683eb41afd..a18f2b9dd99782954d90b87c606ad2453decd2b3 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: dhcp.c,v 1.135 2000/01/27 22:21:32 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhcp.c,v 1.136 2000/01/31 23:43:11 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -641,7 +641,7 @@ void dhcpinform (packet)
                oc = (struct option_cache *)0;
                if (option_cache_allocate (&oc, MDL)) {
                        memset (&d1, 0, sizeof d1);
-                       d1.data = "nwip";
+                       d1.data = (const unsigned char *)"nwip";
                        d1.len = 4;
                        if (make_encapsulation (&oc -> expression, &d1)) {
                                oc -> option = dhcp_universe.options [i];
@@ -1843,7 +1843,7 @@ void ack_lease (packet, lease, offer, when, msg)
                oc = (struct option_cache *)0;
                if (option_cache_allocate (&oc, MDL)) {
                        memset (&d1, 0, sizeof d1);
-                       d1.data = "nwip";
+                       d1.data = (const unsigned char *)"nwip";
                        d1.len = 4;
                        if (make_encapsulation (&oc -> expression, &d1)) {
                                oc -> option = dhcp_universe.options [i];
@@ -2652,13 +2652,21 @@ struct lease *mockup_lease (packet, share, hp)
        struct host_decl *hp;
 {
        static struct lease mock;
+       const unsigned char **s;
        
        mock.subnet = find_host_for_network (&hp, &mock.ip_addr, share);
        if (!mock.subnet)
                return (struct lease *)0;
        mock.next = mock.prev = (struct lease *)0;
        mock.host = hp;
-       (const unsigned char *)mock.uid = hp -> client_identifier.data;
+       if (hp -> client_identifier.len > sizeof mock.uid_buf)
+               mock.uid = dmalloc (hp -> client_identifier.len, MDL);
+       else
+               mock.uid = mock.uid_buf;
+       if (!mock.uid)
+               return (struct lease *)0;
+       memcpy (mock.uid, hp -> client_identifier.data,
+               hp -> client_identifier.len);
        mock.uid_len = hp -> client_identifier.len;
        mock.hardware_addr = hp -> interface;
        mock.starts = mock.timestamp = mock.ends = MIN_TIME;
@@ -2689,6 +2697,10 @@ void static_lease_dereference (lease, file, line)
                                                  file, line);
        if (&lease -> scope)
                free_bindings (&lease -> scope, file, line);
+       if (lease -> uid != lease -> uid_buf) {
+               dfree (lease -> uid, file, line);
+               lease -> uid = (unsigned char *)0;
+       }
 }
 
 /* Look through all the pools in a list starting with the specified pool