[systemd-devel] [PATCH 3/4] sd-dhcp-client: fix invalid free() in client_send_request()

Andreas Henriksson andreas at fatal.se
Fri Jun 13 09:48:20 PDT 2014


static int client_send_request(...) in
./src/libsystemd-network/sd-dhcp-client.c tries to initialize
"request" by calling client_message_init(...), which has atleast
5 error cases where it can return without that happening.
This leads to the function finishing without "request" being initialized.

Signed-off-by: Andreas Henriksson <andreas at fatal.se>
---
 src/libsystemd-network/sd-dhcp-client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index 8f54906..2a46624 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -413,7 +413,7 @@ static int client_send_discover(sd_dhcp_client *client) {
 }
 
 static int client_send_request(sd_dhcp_client *client) {
-        _cleanup_free_ DHCPPacket *request;
+        _cleanup_free_ DHCPPacket *request = NULL;
         size_t optoffset, optlen;
         int r;
 
-- 
2.0.0



More information about the systemd-devel mailing list