sd-dhcp-server: clear buffer before receive
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 11 Jun 2024 15:48:56 +0000 (00:48 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 18 Jun 2024 18:41:01 +0000 (20:41 +0200)
I do not think this is necessary, but all other places in
libsystemd-network we clear buffer before receive. Without this,
Coverity warns about use-of-uninitialized-values.
Let's silence Coverity.

Closes CID#1469721.

(cherry picked from commit 40f9fa0af4c3094d93e833e62f7e301cd453da62)

src/libsystemd-network/sd-dhcp-server.c

index c3b0f82dc4f87dfd4a69446241d636f888b54d01..4967f066dce5f8901df7e324c20cc414cb202fdf 100644 (file)
@@ -1252,7 +1252,7 @@ static int server_receive_message(sd_event_source *s, int fd,
                 /* Preallocate the additional size for DHCP Relay Agent Information Option if needed */
                 buflen += relay_agent_information_length(server->agent_circuit_id, server->agent_remote_id) + 2;
 
-        message = malloc(buflen);
+        message = malloc0(buflen);
         if (!message)
                 return -ENOMEM;