diff mbox series

[3/3] dhcp-transport: Initialize the udp_fd field

Message ID 20220507235434.11693-4-greg@gregdf.com (mailing list archive)
State Accepted, archived
Headers show
Series [1/3] main: Accept FD 0 as epoll_fd | expand

Commit Message

Greg Depoire--Ferrer May 7, 2022, 11:54 p.m. UTC
Initialize the udp_fd field to -1 in _dhcp_default_transport_new to
prevent future mistakes where a random FD is closed when the transport
is closed before the field is initialized.
---
 ell/dhcp-transport.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Denis Kenzior June 6, 2022, 6:17 p.m. UTC | #1
Hi Greg,

On 5/7/22 18:54, Greg Depoire--Ferrer wrote:
> Initialize the udp_fd field to -1 in _dhcp_default_transport_new to
> prevent future mistakes where a random FD is closed when the transport
> is closed before the field is initialized.
> ---
>   ell/dhcp-transport.c | 1 +
>   1 file changed, 1 insertion(+)
> 

This mailing list isn't quite live yet, so I somehow managed to miss this 
series.  Sorry about that.  Wish I didn't since it would have saved me some time :(

Anyhow, there was a related fix applied as commit:

f5fccbab31e6 ("dhcp-transport: Do not leak fds during bind")

Regards,
-Denis
diff mbox series

Patch

diff --git a/ell/dhcp-transport.c b/ell/dhcp-transport.c
index d73930b..8ab6327 100644
--- a/ell/dhcp-transport.c
+++ b/ell/dhcp-transport.c
@@ -550,6 +550,7 @@  struct dhcp_transport *_dhcp_default_transport_new(uint32_t ifindex,
 	transport->super.ifindex = ifindex;
 	l_strlcpy(transport->ifname, ifname, IFNAMSIZ);
 	transport->port = port;
+	transport->udp_fd = -1;
 
 	return &transport->super;
 }