From 663e41f353a0e7c65be979a35f04de74bdd139fa Mon Sep 17 00:00:00 2001 From: Pavel Zhukov Date: Dec 08 2017 10:34:35 +0000 Subject: Properly close omapi connection (#1523547) --- diff --git a/dhcp-4.3.6-omapi-leak.patch b/dhcp-4.3.6-omapi-leak.patch new file mode 100644 index 0000000..0ffcfe3 --- /dev/null +++ b/dhcp-4.3.6-omapi-leak.patch @@ -0,0 +1,52 @@ +commit ccff9ed69d0b26d33ce9cac8e83dab535b64d627 +Author: Thomas Markwalder +Date: Tue Dec 5 15:12:34 2017 -0500 + + [46767] Plugged a socket descriptor leak in OMAPI + + If disconnect is triggered by the reader closing the socket, while there + is data left to write, the socket would be orphaned. + + omapip/buffer.c + omapi_connection_writea() - added logic to recall disconnect once + pending data has been written + + omapip/message.c + Removed static declaration from omapi_message_unregister so you can + actually compile when DEBUG_PROTOCOL is defined. + + Added a release note + +diff --git a/omapip/buffer.c b/omapip/buffer.c +index 6e0621b..a21f0a8 100644 +--- a/omapip/buffer.c ++++ b/omapip/buffer.c +@@ -565,6 +565,15 @@ isc_result_t omapi_connection_writer (omapi_object_t *h) + omapi_buffer_dereference (&buffer, MDL); + } + } ++ ++ /* If we had data left to write when we're told to disconnect, ++ * we need recall disconnect, now that we're done writing. ++ * See rt46767. */ ++ if (c->out_bytes == 0 && c->state == omapi_connection_disconnecting) { ++ omapi_disconnect (h, 1); ++ return ISC_R_SHUTTINGDOWN; ++ } ++ + return ISC_R_SUCCESS; + } + +diff --git a/omapip/message.c b/omapip/message.c +index ee15d82..37abbd2 100644 +--- a/omapip/message.c ++++ b/omapip/message.c +@@ -339,7 +339,7 @@ isc_result_t omapi_message_unregister (omapi_object_t *mo) + } + + #ifdef DEBUG_PROTOCOL +-static const char *omapi_message_op_name(int op) { ++const char *omapi_message_op_name(int op) { + switch (op) { + case OMAPI_OP_OPEN: return "OMAPI_OP_OPEN"; + case OMAPI_OP_REFRESH: return "OMAPI_OP_REFRESH"; diff --git a/dhcp.spec b/dhcp.spec index 8abe86c..52f7de0 100644 --- a/dhcp.spec +++ b/dhcp.spec @@ -19,7 +19,7 @@ Summary: Dynamic host configuration protocol software Name: dhcp Version: 4.3.5 -Release: 9%{?dist} +Release: 10%{?dist} # NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to # dcantrell maintaining the package) made incorrect use of the epoch and # that's why it is at 12 now. It should have never been used, but it was. @@ -78,6 +78,7 @@ Patch36: dhcp-option97-pxe-client-id.patch Patch37: dhcp-stateless-DUID-LLT.patch Patch38: dhcp-dhclient-preinit6s.patch Patch39: dhcp-dhclient-ddns_lazy.patch +Patch40: dhcp-4.3.6-omapi-leak.patch BuildRequires: autoconf BuildRequires: automake @@ -347,6 +348,10 @@ rm bind/bind.tar.gz ## Subject: [ISC-Bugs #45290] [PATCH] ISC-BUGS #33377 dhclient: Don't listen on ddns port by default. %patch39 -p1 -b .ddnslazy +# close omapi socker descriptions properly +# https://bugzilla.redhat.com/1523547 +%patch40 -p1 -b .omapi-leak + # DHCLIENT_DEFAULT_PREFIX_LEN 64 -> 128 # https://bugzilla.gnome.org/show_bug.cgi?id=656610 sed -i -e 's|DHCLIENT_DEFAULT_PREFIX_LEN 64|DHCLIENT_DEFAULT_PREFIX_LEN 128|g' includes/site.h @@ -674,6 +679,9 @@ done %endif %changelog +* Fri Dec 8 2017 Pavel Zhukov - 12:4.3.5-10 +- Fix omapi SD leak (#1523547) + * Tue Aug 1 2017 Pavel Zhukov - 12:4.3.5-9 - Fix typos in dhclient-script