2019-08-28 07:11:49

by Patrick Steinhardt

[permalink] [raw]
Subject: [PATCH 4/6] configure.ac: Add <sys/socket.h> header when checking sizeof(socklen_t)

We're checking for various sizes in configure.ac, among them the size of
the socklen_t type. If socklen_t's size is not found and thus reported
to be zero, we will typedef our own socklen_t as "unsigned int".

The check for socklen_t is insufficient, though. While the type is
declared via <sys/socket.h>, we only search AC_INCLUDES_DEFAULT for its
declaration, which doesn't include <sys/socket.h>. On musl libc, this
causes us to not find the declaration and redeclare it with an
incompatible type.

Fix the issue by searching both the default includes as well as
<sys/socket.h>.

Signed-off-by: Patrick Steinhardt <[email protected]>
---
configure.ac | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 50002b4a..37096944 100644
--- a/configure.ac
+++ b/configure.ac
@@ -545,7 +545,10 @@ AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(size_t)
-AC_CHECK_SIZEOF(socklen_t)
+AC_CHECK_SIZEOF(socklen_t,, [AC_INCLUDES_DEFAULT
+ #ifdef HAVE_SYS_SOCKET_H
+ # include <sys/socket.h>
+ #endif])


dnl *************************************************************
--
2.23.0