Commit f1dc58d8 authored by Shawn Routhier's avatar Shawn Routhier
Browse files

[v4_1_esv]

Update the memory leakage debug code to work with v6.
parent b8ee38f1
......@@ -106,6 +106,9 @@ work on other platforms. Please report any problems and suggested fixes to
[ISC-Bugs #30024]
CVE: CVE-2012-3954
- Update the memory leakage debug code to work with v6.
[ISC-Bugs #30297]
Changes since 4.1-ESV-R5rc2
- None
......
......@@ -3743,55 +3743,51 @@ void do_packet (interface, packet, len, from_port, from, hfrom)
#endif
#if defined (TRACING)
trace_inpacket_stash (interface, packet, len, from_port, from, hfrom);
trace_inpacket_stash(interface, packet, len, from_port, from, hfrom);
#endif
decoded_packet = (struct packet *)0;
if (!packet_allocate (&decoded_packet, MDL)) {
log_error ("do_packet: no memory for incoming packet!");
decoded_packet = NULL;
if (!packet_allocate(&decoded_packet, MDL)) {
log_error("do_packet: no memory for incoming packet!");
return;
}
decoded_packet -> raw = packet;
decoded_packet -> packet_length = len;
decoded_packet -> client_port = from_port;
decoded_packet -> client_addr = from;
interface_reference (&decoded_packet -> interface, interface, MDL);
decoded_packet -> haddr = hfrom;
if (packet -> hlen > sizeof packet -> chaddr) {
packet_dereference (&decoded_packet, MDL);
log_info ("Discarding packet with bogus hlen.");
decoded_packet->raw = packet;
decoded_packet->packet_length = len;
decoded_packet->client_port = from_port;
decoded_packet->client_addr = from;
interface_reference(&decoded_packet->interface, interface, MDL);
decoded_packet->haddr = hfrom;
if (packet->hlen > sizeof packet->chaddr) {
packet_dereference(&decoded_packet, MDL);
log_info("Discarding packet with bogus hlen.");
return;
}
/* If there's an option buffer, try to parse it. */
if (decoded_packet -> packet_length >= DHCP_FIXED_NON_UDP + 4) {
if (!parse_options (decoded_packet)) {
if (decoded_packet -> options)
if (decoded_packet->packet_length >= DHCP_FIXED_NON_UDP + 4) {
if (!parse_options(decoded_packet)) {
if (decoded_packet->options)
option_state_dereference
(&decoded_packet -> options, MDL);
(&decoded_packet->options, MDL);
packet_dereference (&decoded_packet, MDL);
return;
}
if (decoded_packet -> options_valid &&
(op = lookup_option (&dhcp_universe,
decoded_packet -> options,
DHO_DHCP_MESSAGE_TYPE))) {
if (decoded_packet->options_valid &&
(op = lookup_option(&dhcp_universe,
decoded_packet->options,
DHO_DHCP_MESSAGE_TYPE))) {
struct data_string dp;
memset (&dp, 0, sizeof dp);
evaluate_option_cache (&dp, decoded_packet,
(struct lease *)0,
(struct client_state *)0,
decoded_packet -> options,
(struct option_state *)0,
(struct binding_scope **)0,
op, MDL);
memset(&dp, 0, sizeof dp);
evaluate_option_cache(&dp, decoded_packet, NULL, NULL,
decoded_packet->options, NULL,
NULL, op, MDL);
if (dp.len > 0)
decoded_packet -> packet_type = dp.data [0];
decoded_packet->packet_type = dp.data[0];
else
decoded_packet -> packet_type = 0;
data_string_forget (&dp, MDL);
decoded_packet->packet_type = 0;
data_string_forget(&dp, MDL);
}
}
......@@ -3803,19 +3799,17 @@ void do_packet (interface, packet, len, from_port, from, hfrom)
}
/* If the caller kept the packet, they'll have upped the refcnt. */
packet_dereference (&decoded_packet, MDL);
packet_dereference(&decoded_packet, MDL);
#if defined (DEBUG_MEMORY_LEAKAGE)
log_info ("generation %ld: %ld new, %ld outstanding, %ld long-term",
dmalloc_generation,
dmalloc_outstanding - previous_outstanding,
dmalloc_outstanding, dmalloc_longterm);
#endif
#if defined (DEBUG_MEMORY_LEAKAGE)
dmalloc_dump_outstanding ();
log_info("generation %ld: %ld new, %ld outstanding, %ld long-term",
dmalloc_generation,
dmalloc_outstanding - previous_outstanding,
dmalloc_outstanding, dmalloc_longterm);
dmalloc_dump_outstanding();
#endif
#if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY)
dump_rc_history (0);
dump_rc_history(0);
#endif
}
......@@ -3849,6 +3843,9 @@ do_packet6(struct interface_info *interface, const char *packet,
const struct dhcpv6_packet *msg;
const struct dhcpv6_relay_packet *relay;
struct packet *decoded_packet;
#if defined (DEBUG_MEMORY_LEAKAGE)
unsigned long previous_outstanding = dmalloc_outstanding;
#endif
if (!packet6_len_okay(packet, len)) {
log_info("do_packet6: "
......@@ -3876,8 +3873,8 @@ do_packet6(struct interface_info *interface, const char *packet,
/* decoded_packet->circuit_id_len = 0; */
/* decoded_packet->remote_id = NULL; */
/* decoded_packet->remote_id_len = 0; */
decoded_packet->raw = (struct dhcp_packet *) packet;
decoded_packet->packet_length = (unsigned) len;
decoded_packet->raw = (struct dhcp_packet *)packet;
decoded_packet->packet_length = (unsigned)len;
decoded_packet->client_port = from_port;
decoded_packet->client_addr = *from;
interface_reference(&decoded_packet->interface, interface, MDL);
......@@ -3929,6 +3926,17 @@ do_packet6(struct interface_info *interface, const char *packet,
dhcpv6(decoded_packet);
packet_dereference(&decoded_packet, MDL);
#if defined (DEBUG_MEMORY_LEAKAGE)
log_info("generation %ld: %ld new, %ld outstanding, %ld long-term",
dmalloc_generation,
dmalloc_outstanding - previous_outstanding,
dmalloc_outstanding, dmalloc_longterm);
dmalloc_dump_outstanding();
#endif
#if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY)
dump_rc_history(0);
#endif
}
#endif /* DHCPv6 */
......
......@@ -18,4 +18,16 @@ file dhcpd
b lease_reference
@endverbatim
DEBUG_MEMORY_LEAKAGE may be defined in includes/site.h to enable some debugging
code to help with debugging memory issues. This code keeps a running total
of the outstanding memory that has been allocated and a list of the outstanding
allocations. Both are updated whent he memory is freed. Status information is
printed when do_packet() and do_packet6() complete processing. The outstanding
value is expected to grow when new structures are used - for example when a new
IPv6 lease is created. It is not expected to grow when a structure is reused
for example when an IPv6 lease is renewed.
DEBUG_RC_HISTORY and DEBUG_RC_HISTORY_EXHAUSTIVELY can also be defined to provide
more verbose information about reference counts on objects.
*/
......@@ -4,6 +4,7 @@
protocol... */
/*
* Copyright (c) 2012 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) 1999-2003 by Internet Software Consortium
......@@ -311,7 +312,7 @@ void dmalloc_dump_outstanding ()
inhistory = 1;
if (!noted) {
log_info (" %s(%d): %ld", dp -> file,
dp -> line, dp -> size);
dp -> line, (long) dp -> size);
noted = 1;
}
print_rc_hist_entry (i);
......@@ -324,7 +325,8 @@ void dmalloc_dump_outstanding ()
if (!inhistory)
#endif
log_info (" %s(%d): %ld",
dp -> file, dp -> line, dp -> size);
dp -> file, dp -> line,
(long) dp -> size);
}
#endif
}
......
......@@ -3,7 +3,8 @@
Memory allocation for the DHCP server... */
/*
* Copyright (c) 2004-2007,2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2009,2012 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
......@@ -61,7 +62,9 @@ void relinquish_lease_hunks ()
if (!c) {
log_info ("lease %s refcnt %d",
piaddr (n [i].ip_addr), n [i].refcnt);
#if defined (DEBUG_RC_HISTORY)
dump_rc_history (&n [i]);
#endif
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment