]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Minor code cleanups - but note port change for #23196
authorShawn Routhier <sar@isc.org>
Wed, 11 May 2011 00:38:56 +0000 (00:38 +0000)
committerShawn Routhier <sar@isc.org>
Wed, 11 May 2011 00:38:56 +0000 (00:38 +0000)
[ISC-Bugs #23470] - Modify when an ignore return macro is defined to
handle unsed error return warnings for more versions of gcc.
[ISC-Bugs #23196] - Modify the reply handling in the server code to
send to a specified port rather than to the source port for the incoming
message.  Sending to the source port was test code that should have
been removed.  The previous functionality may be restored by defining
REPLY_TO_SOURCE_PORT in the includes/site.h file.  We suggest you don't
enable this except for testing purposes.
[ISC-Bugs #22695] - Close a file descriptor in an error path.
[ISC-Bugs #19368] - Tidy up variable types in validate_port.

RELNOTES
client/dhclient.c
common/inet.c
includes/cdefs.h
includes/site.h
server/dhcpv6.c

index 6a2dbaa24907796e75af8dbbbd46649a206ea07f..0985bba14254363e8255ab3d2d27ca41b6c4b54d 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -124,6 +124,18 @@ work on other platforms. Please report any problems and suggested fixes to
   rather than sockaddr. Packet ethertype is now forced to ETH_P_IP. 
   [ISC-Bugs #18975]
 
+- Minor code cleanups - but note port change for #23196
+  [ISC-Bugs #23470] - Modify when an ignore return macro is defined to
+  handle unsed error return warnings for more versions of gcc.
+  [ISC-Bugs #23196] - Modify the reply handling in the server code to
+  send to a specified port rather than to the source port for the incoming
+  message.  Sending to the source port was test code that should have
+  been removed.  The previous functionality may be restored by defining
+  REPLY_TO_SOURCE_PORT in the includes/site.h file.  We suggest you don't
+  enable this except for testing purposes.
+  [ISC-Bugs #22695] - Close a file descriptor in an error path.
+  [ISC-Bugs #19368] - Tidy up variable types in validate_port.
+
                        Changes since 4.2.0
 
 - Documentation cleanup covering multiple tickets
index 30ecb15c33089fa458c14381c7cd408f1a7fec51..5d556cdeae96feae2226699a00fef976b5895c29 100644 (file)
@@ -3445,9 +3445,10 @@ void write_client_pid_file ()
        }
 
        pf = fdopen (pfdesc, "w");
-       if (!pf)
+       if (!pf) {
+               close(pfdesc);
                log_error ("Can't fdopen %s: %m", path_dhclient_pid);
-       else {
+       else {
                fprintf (pf, "%ld\n", (long)getpid ());
                fclose (pf);
        }
index 1d1e6c53ae4ae64229a7449ce386afbf6a4140b6..39845a827cea044c852a5f45adb32b662897fe31 100644 (file)
@@ -4,7 +4,9 @@
    way... */
 
 /*
- * Copyright (c) 2004,2005,2007-2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2007-2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004,2005 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
@@ -610,9 +612,9 @@ piaddrcidr(const struct iaddr *addr, unsigned int bits) {
 
 u_int16_t
 validate_port(char *port) {
-       int local_port = 0;
-       int lower = 1;
-       int upper = 65535;
+       long local_port = 0;
+       long lower = 1;
+       long upper = 65535;
        char *endptr;
 
        errno = 0;
@@ -622,8 +624,8 @@ validate_port(char *port) {
                log_fatal ("Invalid port number specification: %s", port);
 
        if (local_port < lower || local_port > upper)
-               log_fatal("Port number specified is out of range (%d-%d).",
+               log_fatal("Port number specified is out of range (%ld-%ld).",
                          lower, upper);
 
-       return htons(local_port);
+       return htons((u_int16_t)local_port);
 }
index 0468c8e40e630b5710f3bd0c64fc462a05fd1154..a0459e6847554a7ff1de4ebfb292790ed8c3c1a6 100644 (file)
@@ -4,6 +4,7 @@
 
 /*
  * Copyright (c) 1995 RadioMail Corporation.  All rights reserved.
+ * Copyright (c) 2011 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 2004,2009 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1996-2003 by Internet Software Consortium
  *
@@ -62,8 +63,7 @@
  * these warnings prohibit the compilation of the package.  This macro
  * allows us to assign the return value to a variable and then ignore it.
  */
-#if !defined(__GNUC__) || (__GNUC__ < 4) || \
-       ((__GNUC__ == 4) && (__GNUC_MINOR__ < 3))
+#if !defined(__GNUC__) || (__GNUC__ < 4)
 #define IGNORE_RET(x) (void) x
 #else
 #define IGNORE_RET(x)                  \
index 91a5d98f10426938a281e86b8b07f6c44752d25e..22505a4ba0598e32ee1cafba77c821ef2b1c011b 100644 (file)
 
 /* #define USE_OLD_DDNS_TTL */
 
+/* Define this if you want a DHCPv6 server to send replies to the
+   source port of the message it received.  This is useful for testing
+   but is only included for backwards compatibility. */
+/* #define REPLY_TO_SOURCE_PORT */
index 83fa1adfc03f49c06bf1ddc8ca27eae7ee569c4e..2e88d7fba3f46476b556e66391c07508c6383fdf 100644 (file)
@@ -5884,8 +5884,18 @@ dhcpv6(struct packet *packet) {
                } else {
                        to_addr.sin6_port = remote_port;
                }
-/* For testing, we reply to the sending port, so we don't need a root client */
+
+#if defined (REPLY_TO_SOURCE_PORT)
+               /*
+                * This appears to have been included for testing so we would
+                * not need a root client, but was accidently left in the
+                * final code.  We continue to include it in case
+                * some users have come to rely upon it, but leave
+                * it off by default as it's a bad idea.
+                */
                to_addr.sin6_port = packet->client_port;
+#endif
+
                memcpy(&to_addr.sin6_addr, packet->client_addr.iabuf, 
                       sizeof(to_addr.sin6_addr));