[PATCH] bsd/ntpq: Use the correct address length
Kinsey Moore
kinsey.moore at oarcorp.com
Thu Sep 21 18:38:09 UTC 2023
lwIP includes more than the bare address structures in its accounting of
the total addrinfo struct size. Ensure that lwIP gets the correct
address size.
---
bsd/freebsd/contrib/ntp/ntpq/ntpq.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/bsd/freebsd/contrib/ntp/ntpq/ntpq.c b/bsd/freebsd/contrib/ntp/ntpq/ntpq.c
index 1cea922..0ea6c08 100644
--- a/bsd/freebsd/contrib/ntp/ntpq/ntpq.c
+++ b/bsd/freebsd/contrib/ntp/ntpq/ntpq.c
@@ -828,6 +828,14 @@ openhost(
#ifdef SYS_VXWORKS
(connect(sockfd, (struct sockaddr *)&hostaddr,
sizeof(hostaddr)) == -1)
+#elif defined(__rtems__)
+ /*
+ * lwIP's ai_addrlen covers the entire struct which includes
+ * padding for extra data and is not accurate for calls which
+ * validate the size of the address structure. Use sa_len instead
+ */
+ (connect(sockfd, (struct sockaddr *)ai->ai_addr,
+ ai->ai_addr->sa_len) == -1)
#else
(connect(sockfd, (struct sockaddr *)ai->ai_addr,
ai->ai_addrlen) == -1)
--
2.39.2
More information about the devel
mailing list