Skip to content

Commit

Permalink
Properly autoconf-ize HAVE_SOCKADDR_IN_SIN_LEN
Browse files Browse the repository at this point in the history
  • Loading branch information
thorpej committed Mar 3, 2023
1 parent f2404fc commit fe8a910
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 7 deletions.
3 changes: 3 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
/* Define to 1 if you have <Security/SecureTransport.h> */
#undef HAVE_SECURETRANSPORT

/* Define if the struct sockaddr_in has a member sin_len on your OS */
#undef HAVE_SOCKADDR_IN_SIN_LEN

/* Define if the struct sockaddr_un has a member sun_len on your OS */
#undef HAVE_SOCKADDR_UN_SUN_LEN

Expand Down
37 changes: 37 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -14191,6 +14191,43 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu



# Check for struct sockaddr_in::sin_len.
#
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sin_len member in struct sockaddr_in" >&5
printf %s "checking for sin_len member in struct sockaddr_in... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/socket.h>
#include <netinet/in.h>
int
main (void)
{
struct sockaddr_in dummy;
dummy.sin_len = 0;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :


printf "%s\n" "#define HAVE_SOCKADDR_IN_SIN_LEN 1" >>confdefs.h

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
else $as_nop

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext

# Check for struct sockaddr_un::sun_len.
#
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sun_len member in struct sockaddr_un" >&5
Expand Down
15 changes: 15 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,21 @@ m4_include([m4/ax_pthread.m4])
AX_PTHREAD([],
[AC_MSG_ERROR([Missing POSIX threads])])

# Check for struct sockaddr_in::sin_len.
#
AC_MSG_CHECKING(for sin_len member in struct sockaddr_in)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
#include <sys/socket.h>
#include <netinet/in.h>
]],[[
struct sockaddr_in dummy;
dummy.sin_len = 0;
]])],[
AC_DEFINE(HAVE_SOCKADDR_IN_SIN_LEN, 1, [Define if the struct sockaddr_in has a member sin_len on your OS])
AC_MSG_RESULT(yes)],[
AC_MSG_RESULT(no)])

# Check for struct sockaddr_un::sun_len.
#
AC_MSG_CHECKING(for sun_len member in struct sockaddr_un)
Expand Down
6 changes: 0 additions & 6 deletions libfetch/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@
#include <openssl/err.h>
#endif

#if !defined(__sun) && !defined(__hpux) && !defined(__INTERIX) && \
!defined(__digital__) && !defined(__linux) && !defined(__MINT__) && \
!defined(__sgi)
#define HAVE_SA_LEN
#endif

/* Connection */
typedef struct fetchconn conn_t;

Expand Down
2 changes: 1 addition & 1 deletion libfetch/ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ unmappedaddr(struct sockaddr_in6 *sin6, socklen_t *len)
sin4->sin_port = port;
sin4->sin_family = AF_INET;
*len = sizeof(struct sockaddr_in);
#ifdef HAVE_SA_LEN
#ifdef HAVE_SOCKADDR_IN_SIN_LEN
sin4->sin_len = sizeof(struct sockaddr_in);
#endif
}
Expand Down

0 comments on commit fe8a910

Please sign in to comment.