]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Another batch of fixes
authorShawn Routhier <sar@isc.org>
Thu, 9 Sep 2010 22:18:02 +0000 (22:18 +0000)
committerShawn Routhier <sar@isc.org>
Thu, 9 Sep 2010 22:18:02 +0000 (22:18 +0000)
 Correct error handling in DLPI [ISC-Bugs #20378]
 Remove __sun__ and __hpux__ typedefs in osdep.h as they are now being
 checked in configure.  [ISC-Bugs #20443]
 Modify how the cmsg header is allocated the v6 send and received routines
 to compile on more compilers.  [ISC-Bugs #20524]
 When parsing a domain name free the memory for the name after we are
 done with it.  [ISC-Bugs #20824]

RELNOTES
common/dlpi.c
common/parse.c
common/socket.c
includes/osdep.h

index bc6b009637b33e821c8f0c5a131856bd58fb599c..bc1a82501b998e4c3b3f6e9ca1548ead707ba60c 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -85,6 +85,17 @@ work on other platforms. Please report any problems and suggested fixes to
   [ISC-Bugs #21497] Add a little more randomness to rng seed in client
   thanks to a patch from Jeremiah Jinno.
 
+- Correct error handling in DLPI [ISC-Bugs #20378]
+
+- Remove __sun__ and __hpux__ typedefs in osdep.h as they are now being
+  checked in configure.  [ISC-Bugs #20443]
+
+- Modify how the cmsg header is allocated the v6 send and received routines
+  to compile on more compilers.  [ISC-Bugs #20524]
+
+- When parsing a domain name free the memory for the name after we are
+  done with it.  [ISC-Bugs #20824]
+
                        Changes since 4.2.0b2
 
 - Add declaration for variable in debug code in alloc.c.  [ISC-Bugs #21472]
index eb64342c7b36f7ce427749aec2b1105c86418b4c..002480ff647e2124ca7760114a63ac4ab020212c 100644 (file)
@@ -3,7 +3,8 @@
    Data Link Provider Interface (DLPI) network interface code. */
 
 /*
- * Copyright (c) 2004,2007,2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2009-2010 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1996-2003 by Internet Software Consortium
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -981,7 +982,7 @@ static int dlpibindack (fd, bufp)
        
        dlp = (union DL_primitives *)ctl.buf;
        
-       if (!expected (DL_BIND_ACK, dlp, flags) < 0) {
+       if (expected (DL_BIND_ACK, dlp, flags) == -1) {
                return -1;
        }
        
@@ -1015,7 +1016,7 @@ static int dlpiokack (fd, bufp)
        
        dlp = (union DL_primitives *)ctl.buf;
        
-       if (!expected (DL_OK_ACK, dlp, flags) < 0) {
+       if (expected (DL_OK_ACK, dlp, flags) == -1) {
                return -1;
        }
        
@@ -1049,7 +1050,7 @@ static int dlpiinfoack (fd, bufp)
        
        dlp = (union DL_primitives *) ctl.buf;
        
-       if (!expected (DL_INFO_ACK, dlp, flags) < 0) {
+       if (expected (DL_INFO_ACK, dlp, flags) == -1) {
                return -1;
        }
        
@@ -1083,7 +1084,7 @@ int dlpiphysaddrack (fd, bufp)
 
        dlp = (union DL_primitives *)ctl.buf;
        
-       if (!expected (DL_PHYS_ADDR_ACK, dlp, flags) < 0) {
+       if (expected (DL_PHYS_ADDR_ACK, dlp, flags) == -1) {
                return -1;
        }
 
@@ -1225,15 +1226,15 @@ static int expected (prim, dlp, msgflags)
 {
        if (msgflags != RS_HIPRI) {
                /* Message was not M_PCPROTO */
-               return 0;
+               return -1;
        }
 
-       if (dlp -> dl_primitive != prim) {
+       if (dlp->dl_primitive != prim) {
                /* Incorrect/unexpected return message */
-               return 0;
+               return -1;
        }
        
-       return 1;
+       return 0;
 }
 
 /*
index 0d9626095e37bf048adface6c2a636c0756bf4df..35224b3d7a1d74f5d5587cc2c0b1d68202e8f0b3 100644 (file)
@@ -3,7 +3,7 @@
    Common parser code for dhcpd and dhclient. */
 
 /*
- * Copyright (c) 2004-2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1995-2003 by Internet Software Consortium
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -5082,6 +5082,7 @@ int parse_option_token (rv, cfile, fmt, expr, uniform, lookups)
        unsigned len;
        struct iaddr addr;
        int compress;
+       isc_boolean_t freeval = ISC_FALSE;
        const char *f, *g;
        struct enumeration_value *e;
 
@@ -5165,6 +5166,7 @@ int parse_option_token (rv, cfile, fmt, expr, uniform, lookups)
                        return 0;
                }
                len = strlen (val);
+               freeval = ISC_TRUE;
                goto make_string;
 
              case 't': /* Text string... */
@@ -5181,6 +5183,10 @@ int parse_option_token (rv, cfile, fmt, expr, uniform, lookups)
                if (!make_const_data (&t, (const unsigned char *)val,
                                      len, 1, 1, MDL))
                        log_fatal ("No memory for concatenation");
+               if (freeval == ISC_TRUE) {
+                       dfree((char *)val, MDL);
+                       freeval = ISC_FALSE;
+               }
                break;
                
              case 'N':
index a05e01c90b6a68d1b92c0761d5d103aa9bc3c59e..3f4eac90a186908eccd51677aabc4db2941e2ee7 100644 (file)
@@ -3,7 +3,7 @@
    BSD socket interface code... */
 
 /*
- * Copyright (c) 2004-2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1995-2003 by Internet Software Consortium
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -566,6 +566,21 @@ static size_t CMSG_SPACE(size_t len) {
 #endif /* DHCPv6 */
 
 #ifdef DHCPv6
+/*
+ * For both send_packet6() and receive_packet6() we need to allocate
+ * space for the cmsg header information.  We do this once and reuse
+ * the buffer.
+ */
+static void   *control_buf = NULL;
+static size_t  control_buf_len = 0;
+
+static void
+allocate_cmsg_cbuf(void) {
+       control_buf_len = CMSG_SPACE(sizeof(struct in6_pktinfo));
+       control_buf = dmalloc(control_buf_len, MDL);
+       return;
+}
+
 /* 
  * For both send_packet6() and receive_packet6() we need to use the 
  * sendmsg()/recvmsg() functions rather than the simpler send()/recv()
@@ -593,10 +608,20 @@ ssize_t send_packet6(struct interface_info *interface,
        int result;
        struct in6_pktinfo *pktinfo;
        struct cmsghdr *cmsg;
-       union {
-               struct cmsghdr cmsg_sizer;
-               u_int8_t pktinfo_sizer[CMSG_SPACE(sizeof(struct in6_pktinfo))];
-       } control_buf;
+
+       /*
+        * If necessary allocate space for the control message header.
+        * The space is common between send and receive.
+        */
+
+       if (control_buf == NULL) {
+               allocate_cmsg_cbuf();
+               if (control_buf == NULL) {
+                       log_error("send_packet6: unable to allocate cmsg header");
+                       return(ENOMEM);
+               }
+       }
+       memset(control_buf, 0, control_buf_len);
 
        /*
         * Initialize our message header structure.
@@ -627,8 +652,8 @@ ssize_t send_packet6(struct interface_info *interface,
         * source address if we wanted, but we can safely let the
         * kernel decide what that should be. 
         */
-       m.msg_control = &control_buf;
-       m.msg_controllen = sizeof(control_buf);
+       m.msg_control = control_buf;
+       m.msg_controllen = control_buf_len;
        cmsg = CMSG_FIRSTHDR(&m);
        cmsg->cmsg_level = IPPROTO_IPV6;
        cmsg->cmsg_type = IPV6_PKTINFO;
@@ -694,10 +719,19 @@ receive_packet6(struct interface_info *interface,
        struct cmsghdr *cmsg;
        struct in6_pktinfo *pktinfo;
        int found_pktinfo;
-       union {
-               struct cmsghdr cmsg_sizer;
-               u_int8_t pktinfo_sizer[CMSG_SPACE(sizeof(struct in6_pktinfo))];
-       } control_buf;
+
+       /*
+        * If necessary allocate space for the control message header.
+        * The space is common between send and receive.
+        */
+       if (control_buf == NULL) {
+               allocate_cmsg_cbuf();
+               if (control_buf == NULL) {
+                       log_error("send_packet6: unable to allocate cmsg header");
+                       return(ENOMEM);
+               }
+       }
+       memset(control_buf, 0, control_buf_len);
 
        /*
         * Initialize our message header structure.
@@ -728,8 +762,8 @@ receive_packet6(struct interface_info *interface,
         * information (when we initialized the interface), so we
         * should get the destination address from that.
         */
-       m.msg_control = &control_buf;
-       m.msg_controllen = sizeof(control_buf);
+       m.msg_control = control_buf;
+       m.msg_controllen = control_buf_len;
 
        result = recvmsg(interface->rfdesc, &m, 0);
 
index 63e676e4ef0651dadff08b8f2716145108c05cac..a8d8bb787840195da940cb0fdb5c6e496c4f567a 100644 (file)
@@ -3,7 +3,7 @@
    Operating system dependencies... */
 
 /*
- * Copyright (c) 2004-2005,2007-2009 by Internet Systems Consortium,
+ * Copyright (c) 2004-2005,2007-2010 by Internet Systems Consortium,
  *                                      Inc. ("ISC")
  * Copyright (c) 1996-2003 by Internet Software Consortium
  *
 #include "config.h"
 
 #include <inttypes.h>
-/* XXX: now that we have a nice autoconf, we should sense this in
- * ./configure.
- */
-#if defined(__sun__) || defined(__hpux__)
-typedef uint8_t u_int8_t;
-typedef uint16_t u_int16_t;
-typedef uint32_t u_int32_t;
-#endif
 
 #ifndef LITTLE_ENDIAN
 #define LITTLE_ENDIAN 1234