From: Greg Depoire--Ferrer <greg@gregdf.com>
To: ell@lists.linux.dev
Cc: Greg Depoire--Ferrer <greg@gregdf.com>
Subject: [PATCH 2/3] dhcp6-transport: Remove udp_fd field
Date: Sun, 8 May 2022 01:54:33 +0200 [thread overview]
Message-ID: <20220507235434.11693-3-greg@gregdf.com> (raw)
In-Reply-To: <20220507235434.11693-1-greg@gregdf.com>
_dhcp6_default_transport_new forgot to initialize the udp_fd field to a
negative value. Because of this, _dhcp6_default_transport_close would
try to close it. For instance, this could end up closing FD 0 (stdin) if
memory allocation returned was zeroed.
However, udp_fd is not actually used and is a left over from from the
dhcp-transport.c file that was copied to implement DHCPv6 in commit
b384838d1a79182f09b71a7a48d103ff790b8ae6 ("dhcp6: Add dhcp6 transport
abstraction and default"), so it can just be removed.
---
ell/dhcp6-transport.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/ell/dhcp6-transport.c b/ell/dhcp6-transport.c
index 04bf4fb..8d15606 100644
--- a/ell/dhcp6-transport.c
+++ b/ell/dhcp6-transport.c
@@ -45,7 +45,6 @@
struct dhcp6_default_transport {
struct dhcp6_transport super;
struct l_io *io;
- int udp_fd;
uint16_t port;
struct in6_addr local;
};
@@ -214,11 +213,6 @@ static void _dhcp6_default_transport_close(struct dhcp6_transport *s)
l_io_destroy(transport->io);
transport->io = NULL;
-
- if (transport->udp_fd >= 0) {
- L_TFR(close(transport->udp_fd));
- transport->udp_fd = -1;
- }
}
void _dhcp6_transport_set_rx_callback(struct dhcp6_transport *transport,
--
2.35.1
next prev parent reply other threads:[~2022-05-08 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-07 23:54 Fix bug when stdin is closed Greg Depoire--Ferrer
2022-05-07 23:54 ` [PATCH 1/3] main: Accept FD 0 as epoll_fd Greg Depoire--Ferrer
2022-05-07 23:54 ` Greg Depoire--Ferrer [this message]
2022-05-07 23:54 ` [PATCH 3/3] dhcp-transport: Initialize the udp_fd field Greg Depoire--Ferrer
2022-06-06 18:17 ` Denis Kenzior
2022-06-06 18:18 ` Fix bug when stdin is closed Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220507235434.11693-3-greg@gregdf.com \
--to=greg@gregdf.com \
--cc=ell@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).