Module Name:    src
Committed By:   christos
Date:           Wed May 26 22:52:32 UTC 2021

Modified Files:
        src/external/mpl/dhcp/dist/client: dhclient.c
        src/external/mpl/dhcp/dist/common: parse.c
        src/external/mpl/dhcp/dist/common/tests: option_unittest.c
        src/external/mpl/dhcp/dist/relay: dhcrelay.c
        src/external/mpl/dhcp/dist/relay/tests: relay_unittests.c
        src/external/mpl/dhcp/dist/server: dhcpd.c

Log Message:
merge local changes between dhcp-4.4.2 and dhcp-4.4.2-P1


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/mpl/dhcp/dist/client/dhclient.c
cvs rdiff -u -r1.3 -r1.4 src/external/mpl/dhcp/dist/common/parse.c
cvs rdiff -u -r1.2 -r1.3 \
    src/external/mpl/dhcp/dist/common/tests/option_unittest.c
cvs rdiff -u -r1.4 -r1.5 src/external/mpl/dhcp/dist/relay/dhcrelay.c
cvs rdiff -u -r1.2 -r1.3 \
    src/external/mpl/dhcp/dist/relay/tests/relay_unittests.c
cvs rdiff -u -r1.3 -r1.4 src/external/mpl/dhcp/dist/server/dhcpd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/mpl/dhcp/dist/client/dhclient.c
diff -u src/external/mpl/dhcp/dist/client/dhclient.c:1.3 src/external/mpl/dhcp/dist/client/dhclient.c:1.4
--- src/external/mpl/dhcp/dist/client/dhclient.c:1.3	Mon Aug  3 17:10:56 2020
+++ src/external/mpl/dhcp/dist/client/dhclient.c	Wed May 26 18:52:31 2021
@@ -1,11 +1,11 @@
-/*	$NetBSD: dhclient.c,v 1.3 2020/08/03 21:10:56 christos Exp $	*/
+/*	$NetBSD: dhclient.c,v 1.4 2021/05/26 22:52:31 christos Exp $	*/
 
 /* dhclient.c
 
    DHCP Client. */
 
 /*
- * Copyright (c) 2004-2020 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2021 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1995-2003 by Internet Software Consortium
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: dhclient.c,v 1.3 2020/08/03 21:10:56 christos Exp $");
+__RCSID("$NetBSD: dhclient.c,v 1.4 2021/05/26 22:52:31 christos Exp $");
 
 #include "dhcpd.h"
 #include <isc/util.h>
@@ -84,7 +84,7 @@ int decline_wait_time = 10; /* Default t
 #define ASSERT_STATE(state_is, state_shouldbe) {}
 
 #ifndef UNIT_TEST
-static const char copyright[] = "Copyright 2004-2020 Internet Systems Consortium.";
+static const char copyright[] = "Copyright 2004-2021 Internet Systems Consortium.";
 static const char arr [] = "All rights reserved.";
 static const char message [] = "Internet Systems Consortium DHCP Client";
 static const char url [] = "For info, please visit https://www.isc.org/software/dhcp/";;
@@ -241,7 +241,7 @@ add_interfaces(char **ifaces, int niface
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: dhclient.c,v 1.3 2020/08/03 21:10:56 christos Exp $");
+__RCSID("$NetBSD: dhclient.c,v 1.4 2021/05/26 22:52:31 christos Exp $");
 
 #if defined(DHCPv6) && defined(DHCP4o6)
 static void dhcp4o6_poll(void *dummy);
@@ -1230,7 +1230,7 @@ int find_subnet (struct subnet **sp,
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: dhclient.c,v 1.3 2020/08/03 21:10:56 christos Exp $");
+__RCSID("$NetBSD: dhclient.c,v 1.4 2021/05/26 22:52:31 christos Exp $");
 
 void state_reboot (cpp)
 	void *cpp;

Index: src/external/mpl/dhcp/dist/common/parse.c
diff -u src/external/mpl/dhcp/dist/common/parse.c:1.3 src/external/mpl/dhcp/dist/common/parse.c:1.4
--- src/external/mpl/dhcp/dist/common/parse.c:1.3	Mon Aug  3 17:10:56 2020
+++ src/external/mpl/dhcp/dist/common/parse.c	Wed May 26 18:52:31 2021
@@ -1,11 +1,11 @@
-/*	$NetBSD: parse.c,v 1.3 2020/08/03 21:10:56 christos Exp $	*/
+/*	$NetBSD: parse.c,v 1.4 2021/05/26 22:52:31 christos Exp $	*/
 
 /* parse.c
 
    Common parser code for dhcpd and dhclient. */
 
 /*
- * Copyright (c) 2004-2019 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2021 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1995-2003 by Internet Software Consortium
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: parse.c,v 1.3 2020/08/03 21:10:56 christos Exp $");
+__RCSID("$NetBSD: parse.c,v 1.4 2021/05/26 22:52:31 christos Exp $");
 
 #include "dhcpd.h"
 #include <isc/util.h>
@@ -5561,13 +5561,14 @@ int parse_X (cfile, buf, max)
 				skip_to_semi (cfile);
 				return 0;
 			}
-			convert_num (cfile, &buf [len], val, 16, 8);
-			if (len++ > max) {
+			if (len >= max) {
 				parse_warn (cfile,
 					    "hexadecimal constant too long.");
 				skip_to_semi (cfile);
 				return 0;
 			}
+			convert_num (cfile, &buf [len], val, 16, 8);
+			len++;
 			token = peek_token (&val, (unsigned *)0, cfile);
 			if (token == COLON)
 				token = next_token (&val,

Index: src/external/mpl/dhcp/dist/common/tests/option_unittest.c
diff -u src/external/mpl/dhcp/dist/common/tests/option_unittest.c:1.2 src/external/mpl/dhcp/dist/common/tests/option_unittest.c:1.3
--- src/external/mpl/dhcp/dist/common/tests/option_unittest.c:1.2	Sat Apr  7 18:37:29 2018
+++ src/external/mpl/dhcp/dist/common/tests/option_unittest.c	Wed May 26 18:52:31 2021
@@ -1,7 +1,7 @@
-/*	$NetBSD: option_unittest.c,v 1.2 2018/04/07 22:37:29 christos Exp $	*/
+/*	$NetBSD: option_unittest.c,v 1.3 2021/05/26 22:52:31 christos Exp $	*/
 
 /*
- * Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC")
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -131,6 +131,89 @@ ATF_TC_BODY(pretty_print_option, tc)
     }
 }
 
+ATF_TC(parse_X);
+
+ATF_TC_HEAD(parse_X, tc)
+{
+    atf_tc_set_md_var(tc, "descr",
+		      "Verify parse_X survices option too big.");
+}
+
+/* Initializes a parse struct from an input buffer of data. */
+static void init_parse(struct parse *cfile, char* name, char *input) {
+    memset(cfile, 0, sizeof(struct parse));
+    cfile->tlname = name;
+    cfile->lpos = cfile->line = 1;
+    cfile->cur_line = cfile->line1;
+    cfile->prev_line = cfile->line2;
+    cfile->token_line = cfile->cur_line;
+    cfile->cur_line[0] = cfile->prev_line[0] = 0;
+    cfile->file = -1;
+    cfile->eol_token = 0;
+
+    cfile->inbuf = input;
+    cfile->buflen = strlen(input);
+    cfile->bufsiz = 0;
+}
+
+/*
+ * This test verifies that parse_X does not overwrite the output
+ * buffer when given input data that exceeds the output buffer
+ * capacity.
+*/
+ATF_TC_BODY(parse_X, tc)
+{
+    struct parse cfile;
+    u_int8_t output[10];
+    unsigned len;
+
+    /* Input hex literal */
+    char *input = "01:02:03:04:05:06:07:08";
+    unsigned expected_len = 8;
+
+    /* Normal output plus two filler bytes */
+    u_int8_t expected_plus_two[] = {
+        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0xff, 0xff
+    };
+
+    /* Safe output when option is too long */
+    unsigned short_buf_len = 4;
+    u_int8_t expected_too_long[] = {
+        0x01, 0x02, 0x03, 0x04, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+    };
+
+    /* First we'll run one that works normally */
+    memset(output, 0xff, sizeof(output));
+    init_parse(&cfile, "hex_fits", input);
+
+    len = parse_X(&cfile, output, expected_len);
+
+    // Len should match the expected len.
+    if (len != expected_len) {
+	    atf_tc_fail("parse_X failed, output len: %d", len);
+    }
+
+    // We should not have written anything past the end of the buffer.
+    if (memcmp(output, expected_plus_two, sizeof(output))) {
+	    atf_tc_fail("parse_X failed, output does not match expected");
+    }
+
+    // Now we'll try it with a buffer that's too small.
+    init_parse(&cfile, "hex_too_long", input);
+    memset(output, 0xff, sizeof(output));
+
+    len = parse_X(&cfile, output, short_buf_len);
+
+    // On errors, len should be zero.
+    if (len != 0) {
+	    atf_tc_fail("parse_X failed, we should have had an error");
+    }
+
+    // We should not have written anything past the end of the buffer.
+    if (memcmp(output, expected_too_long, sizeof(output))) {
+        atf_tc_fail("parse_X overwrote buffer!");
+    }
+}
 
 /* This macro defines main() method that will call specified
    test cases. tp and simple_test_case names can be whatever you want
@@ -139,6 +222,7 @@ ATF_TP_ADD_TCS(tp)
 {
     ATF_TP_ADD_TC(tp, option_refcnt);
     ATF_TP_ADD_TC(tp, pretty_print_option);
+    ATF_TP_ADD_TC(tp, parse_X);
 
     return (atf_no_error());
 }

Index: src/external/mpl/dhcp/dist/relay/dhcrelay.c
diff -u src/external/mpl/dhcp/dist/relay/dhcrelay.c:1.4 src/external/mpl/dhcp/dist/relay/dhcrelay.c:1.5
--- src/external/mpl/dhcp/dist/relay/dhcrelay.c:1.4	Fri May 21 17:07:37 2021
+++ src/external/mpl/dhcp/dist/relay/dhcrelay.c	Wed May 26 18:52:32 2021
@@ -1,11 +1,11 @@
-/*	$NetBSD: dhcrelay.c,v 1.4 2021/05/21 21:07:37 christos Exp $	*/
+/*	$NetBSD: dhcrelay.c,v 1.5 2021/05/26 22:52:32 christos Exp $	*/
 
 /* dhcrelay.c
 
    DHCP/BOOTP Relay Agent. */
 
 /*
- * Copyright(c) 2004-2020 by Internet Systems Consortium, Inc.("ISC")
+ * Copyright(c) 2004-2021 by Internet Systems Consortium, Inc.("ISC")
  * Copyright(c) 1997-2003 by Internet Software Consortium
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: dhcrelay.c,v 1.4 2021/05/21 21:07:37 christos Exp $");
+__RCSID("$NetBSD: dhcrelay.c,v 1.5 2021/05/26 22:52:32 christos Exp $");
 
 #include "dhcpd.h"
 #include <syslog.h>
@@ -169,7 +169,7 @@ extern int strip_relay_agent_options(str
 static void request_v4_interface(const char* name, int flags);
 
 static const char copyright[] =
-"Copyright 2004-2020 Internet Systems Consortium.";
+"Copyright 2004-2021 Internet Systems Consortium.";
 static const char arr[] = "All rights reserved.";
 static const char message[] =
 "Internet Systems Consortium DHCP Relay Agent";
@@ -264,7 +264,7 @@ char *progname;
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: dhcrelay.c,v 1.4 2021/05/21 21:07:37 christos Exp $");
+__RCSID("$NetBSD: dhcrelay.c,v 1.5 2021/05/26 22:52:32 christos Exp $");
 static const char use_noarg[] = "No argument for command: %s";
 #ifdef RELAY_PORT
 static const char use_port_defined[] = "Port already set, %s inappropriate";
@@ -1465,8 +1465,9 @@ add_relay_agent_options(struct interface
 	return (length);
 }
 
-#ifdef DHCPv6
 #ifndef UNIT_TEST
+
+#ifdef DHCPv6
 /*
  * Parse a downstream argument: [address%]interface[#index].
  */
@@ -2051,14 +2052,12 @@ process_down6(struct packet *packet) {
 	if (if_id.data != NULL)
 		data_string_forget(&if_id, MDL);
 }
-#endif /* UNIT_TEST */
 
 /*
  * Called by the dispatch packet handler with a decoded packet.
  */
 void
 dhcpv6(struct packet *packet) {
-#ifndef UNIT_TEST
 	struct stream_list *dp;
 
 	/* Try all relay-replies downwards. */
@@ -2081,9 +2080,8 @@ dhcpv6(struct packet *packet) {
 
 	log_info("Can't process packet from interface '%s'.",
 		 packet->interface->name);
-#endif /* UNIT_TEST */
 }
-#endif /* DHCPv6 */
+#endif
 
 /* Stub routines needed for linking with DHCP libraries. */
 void
@@ -2181,3 +2179,4 @@ void request_v4_interface(const char* na
         interface_snorf(tmp, (INTERFACE_REQUESTED | flags));
         interface_dereference(&tmp, MDL);
 }
+#endif /* UNIT_TEST */

Index: src/external/mpl/dhcp/dist/relay/tests/relay_unittests.c
diff -u src/external/mpl/dhcp/dist/relay/tests/relay_unittests.c:1.2 src/external/mpl/dhcp/dist/relay/tests/relay_unittests.c:1.3
--- src/external/mpl/dhcp/dist/relay/tests/relay_unittests.c:1.2	Mon Aug  3 17:10:57 2020
+++ src/external/mpl/dhcp/dist/relay/tests/relay_unittests.c	Wed May 26 18:52:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: relay_unittests.c,v 1.2 2020/08/03 21:10:57 christos Exp $	*/
+/*	$NetBSD: relay_unittests.c,v 1.3 2021/05/26 22:52:32 christos Exp $	*/
 
 /*
  * Copyright (c) 2019-2020 by Internet Systems Consortium, Inc. ("ISC")
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: relay_unittests.c,v 1.2 2020/08/03 21:10:57 christos Exp $");
+__RCSID("$NetBSD: relay_unittests.c,v 1.3 2021/05/26 22:52:32 christos Exp $");
 
 #include "config.h"
 #include <atf-c.h>
@@ -411,3 +411,29 @@ ATF_TP_ADD_TCS(tp) {
 
     return (atf_no_error());
 }
+
+/* Below are dummy function definitions to satisfy "required" symbols */
+isc_result_t find_class (struct class **c, const char *s,
+                         const char *file, int line) {
+	return 0;
+}
+
+int check_collection (struct packet *packet, struct lease *lease,
+                      struct collection *collection) {
+	return 0;
+}
+
+void classify (struct packet *packet, struct class *class){}
+void bootp(struct packet *packet){}
+void dhcp(struct packet *packet){}
+void dhcpv6(struct packet *packet){}
+
+int parse_allow_deny (struct option_cache **oc, struct parse *cfile,
+                      int flag) {
+    return 0;
+}
+
+isc_result_t dhcp_set_control_state (control_object_state_t oldstate,
+                                     control_object_state_t newstate) {
+    return (ISC_R_SUCCESS);
+}

Index: src/external/mpl/dhcp/dist/server/dhcpd.c
diff -u src/external/mpl/dhcp/dist/server/dhcpd.c:1.3 src/external/mpl/dhcp/dist/server/dhcpd.c:1.4
--- src/external/mpl/dhcp/dist/server/dhcpd.c:1.3	Mon Aug  3 17:10:57 2020
+++ src/external/mpl/dhcp/dist/server/dhcpd.c	Wed May 26 18:52:32 2021
@@ -1,11 +1,11 @@
-/*	$NetBSD: dhcpd.c,v 1.3 2020/08/03 21:10:57 christos Exp $	*/
+/*	$NetBSD: dhcpd.c,v 1.4 2021/05/26 22:52:32 christos Exp $	*/
 
 /* dhcpd.c
 
    DHCP Server Daemon. */
 
 /*
- * Copyright (c) 2004-2020 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2021 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1996-2003 by Internet Software Consortium
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -29,10 +29,10 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: dhcpd.c,v 1.3 2020/08/03 21:10:57 christos Exp $");
+__RCSID("$NetBSD: dhcpd.c,v 1.4 2021/05/26 22:52:32 christos Exp $");
 
 static const char copyright[] =
-"Copyright 2004-2020 Internet Systems Consortium.";
+"Copyright 2004-2021 Internet Systems Consortium.";
 static const char arr [] = "All rights reserved.";
 static const char message [] = "Internet Systems Consortium DHCP Server";
 static const char url [] =
@@ -226,7 +226,7 @@ static void omapi_listener_start (void *
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: dhcpd.c,v 1.3 2020/08/03 21:10:57 christos Exp $");
+__RCSID("$NetBSD: dhcpd.c,v 1.4 2021/05/26 22:52:32 christos Exp $");
 static char use_noarg[] = "No argument for command: %s ";
 
 static void

Reply via email to