Blame SOURCES/dhcp-4.2.5-rh1355827.patch

45d60a
--- dhcp-4.2.5.orig/server/mdb.c	2016-05-03 12:46:04.933000000 -0400
45d60a
+++ dhcp-4.2.5/server/mdb.c	2016-05-18 14:38:27.553000000 -0400
45d60a
@@ -720,8 +720,9 @@ void new_address_range (cfile, low, high
45d60a
 {
45d60a
 #if defined(COMPACT_LEASES)
45d60a
 	struct lease *address_range;
45d60a
+	unsigned s;
45d60a
 #endif
45d60a
-	unsigned min, max, i;
45d60a
+	unsigned min, max, i, num_addrs;
45d60a
 	char lowbuf [16], highbuf [16], netbuf [16];
45d60a
 	struct shared_network *share = subnet -> shared_network;
45d60a
 	struct lease *lt = (struct lease *)0;
45d60a
@@ -777,9 +778,29 @@ void new_address_range (cfile, low, high
45d60a
 		min = host_addr (high, subnet -> netmask);
45d60a
 	}
45d60a
 
45d60a
+	/* get the number of addresses we want, and add it to the pool info
45d60a
+	* this value is only for use when setting up lease chains and will
45d60a
+	* be overwritten when expire_all_pools is run
45d60a
+	*/
45d60a
+	num_addrs = max - min + 1;
45d60a
+
45d60a
 	/* Get a lease structure for each address in the range. */
45d60a
 #if defined (COMPACT_LEASES)
45d60a
-	address_range = new_leases (max - min + 1, MDL);
45d60a
+	s = (num_addrs + 1) * sizeof (struct lease);
45d60a
+	 /* Check unsigned overflow in new_leases().
45d60a
+	    With 304 byte lease structure (x86_64), this happens at
45d60a
+	    range 10.0.0.0 10.215.148.52; */
45d60a
+	if (((s % sizeof (struct lease)) != 0) ||
45d60a
+	    ((s / sizeof (struct lease)) != (num_addrs + 1))) {
45d60a
+		strcpy (lowbuf, piaddr (low));
45d60a
+		strcpy (highbuf, piaddr (high));
45d60a
+		parse_warn (cfile, "%s-%s is an overly large address range.",
45d60a
+			   lowbuf, highbuf);
45d60a
+		log_info ("Consider breaking large address ranges into multiple scopes of less than 14 million IPs each.");
45d60a
+		log_info ("For more information, please visit:  https://support.roguewave.com/resources/blogs/openlogic-blogs/how-to-extend-isc-dhcp/");
45d60a
+		log_fatal ("Memory overflow.");
45d60a
+	}
45d60a
+	address_range = new_leases (num_addrs, MDL);
45d60a
 	if (!address_range) {
45d60a
 		strcpy (lowbuf, piaddr (low));
45d60a
 		strcpy (highbuf, piaddr (high));