diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2023-11-12 19:26:45 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2023-11-12 19:26:45 +0300 |
commit | b6737ab39b9df59acad1fe6fb7dc673ddf8e03db (patch) | |
tree | c668e62c90668be2d425a63d92ce982ef5d0acff | |
parent | bcdb52984cc778e0caf280589788b2e04aff3043 (diff) | |
download | libmicrohttpd-b6737ab39b9df59acad1fe6fb7dc673ddf8e03db.tar.gz libmicrohttpd-b6737ab39b9df59acad1fe6fb7dc673ddf8e03db.zip |
Added check for signed socket type
-rw-r--r-- | configure.ac | 49 | ||||
-rw-r--r-- | src/microhttpd/daemon.c | 4 |
2 files changed, 51 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac index f2abfa43..e3cfba07 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -2120,6 +2120,55 @@ AS_VAR_IF([mhd_cv_fd_setsize_overridable],["no"], | |||
2120 | [AC_DEFINE([HAS_FD_SETSIZE_OVERRIDABLE],[1],[Define to 1 i][f your system allow overriding the value of FD_SETSIZE macro])] | 2120 | [AC_DEFINE([HAS_FD_SETSIZE_OVERRIDABLE],[1],[Define to 1 i][f your system allow overriding the value of FD_SETSIZE macro])] |
2121 | ) | 2121 | ) |
2122 | 2122 | ||
2123 | AC_CACHE_CHECK([whether socket value is a signed type],[mhd_cv_socket_signed], | ||
2124 | [ | ||
2125 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ | ||
2126 | #ifdef HAVE_SYS_TIME_H | ||
2127 | #include <sys/time.h> | ||
2128 | #endif | ||
2129 | #ifdef HAVE_SYS_TYPES_H | ||
2130 | #include <sys/types.h> | ||
2131 | #endif | ||
2132 | #ifdef HAVE_UNISTD_H | ||
2133 | #include <unistd.h> | ||
2134 | #endif | ||
2135 | #ifdef HAVE_SYS_SOCKET_H | ||
2136 | #include <sys/socket.h> | ||
2137 | #endif | ||
2138 | #ifdef HAVE_SOCKLIB_H | ||
2139 | #include <sockLib.h> | ||
2140 | #endif | ||
2141 | #if defined(_WIN32) && ! defined(__CYGWIN__) | ||
2142 | #include <winsock2.h> | ||
2143 | #endif | ||
2144 | #ifdef HAVE_SYS_SELECT_H | ||
2145 | #include <sys/select.h> | ||
2146 | #endif | ||
2147 | |||
2148 | /* Keep in sync with microhttpd.h */ | ||
2149 | #if ! defined(_WIN32) || defined(_SYS_TYPES_FD_SET) | ||
2150 | typedef int MHD_socket; | ||
2151 | #else /* defined(_WIN32) && ! defined(_SYS_TYPES_FD_SET) */ | ||
2152 | typedef SOCKET MHD_socket; | ||
2153 | #endif /* defined(_WIN32) && ! defined(_SYS_TYPES_FD_SET) */ | ||
2154 | |||
2155 | int main(void) | ||
2156 | { | ||
2157 | int test_arr[2 - 5*(!!(0 < ((MHD_socket)-1)))]; | ||
2158 | test_arr[1] = 0; | ||
2159 | return test_arr[1]; | ||
2160 | } | ||
2161 | ]] | ||
2162 | ) | ||
2163 | ], | ||
2164 | [mhd_cv_socket_signed="yes"], | ||
2165 | [mhd_cv_socket_signed="no"] | ||
2166 | ) | ||
2167 | ] | ||
2168 | ) | ||
2169 | AS_VAR_IF([mhd_cv_socket_signed],["yes"], | ||
2170 | [AC_DEFINE([HAS_SIGNED_SOCKET],[1],[Define to 1 i][f your socket type is signed])] | ||
2171 | ) | ||
2123 | 2172 | ||
2124 | MHD_CHECK_FUNC([writev], | 2173 | MHD_CHECK_FUNC([writev], |
2125 | [[#include <sys/uio.h>]], | 2174 | [[#include <sys/uio.h>]], |
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 32930a6f..b2420ca8 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -7409,7 +7409,7 @@ process_interim_params (struct MHD_Daemon *d, | |||
7409 | { | 7409 | { |
7410 | (void) 0; /* Use MHD-created socket */ | 7410 | (void) 0; /* Use MHD-created socket */ |
7411 | } | 7411 | } |
7412 | #ifdef MHD_POSIX_SOCKETS | 7412 | #ifdef HAS_SIGNED_SOCKET |
7413 | else if (0 > params->listen_fd) | 7413 | else if (0 > params->listen_fd) |
7414 | { | 7414 | { |
7415 | #ifdef HAVE_MESSAGES | 7415 | #ifdef HAVE_MESSAGES |
@@ -7419,7 +7419,7 @@ process_interim_params (struct MHD_Daemon *d, | |||
7419 | #endif /* HAVE_MESSAGES */ | 7419 | #endif /* HAVE_MESSAGES */ |
7420 | return false; | 7420 | return false; |
7421 | } | 7421 | } |
7422 | #endif /* MHD_POSIX_SOCKETS */ | 7422 | #endif /* HAS_SIGNED_SOCKET */ |
7423 | else if (0 != (d->options & MHD_USE_NO_LISTEN_SOCKET)) | 7423 | else if (0 != (d->options & MHD_USE_NO_LISTEN_SOCKET)) |
7424 | { | 7424 | { |
7425 | #ifdef HAVE_MESSAGES | 7425 | #ifdef HAVE_MESSAGES |