Fixes for the sanitizer

This commit is contained in:
Andras Fekete
2023-09-11 15:57:20 -04:00
parent 42985ebdfa
commit c7f5043774

View File

@ -67,7 +67,11 @@ static int mShutdown = 0;
#ifdef HAVE_SIGNAL #ifdef HAVE_SIGNAL
static void sig_handler(const int sig) static void sig_handler(const int sig)
{ {
#ifdef DEBUG_WOLFSSL
fprintf(stderr, "SIGINT handled = %d.\n", sig); fprintf(stderr, "SIGINT handled = %d.\n", sig);
#else
(void)sig;
#endif
mShutdown = 1; mShutdown = 1;
if (mConnd != SOCKET_INVALID) { if (mConnd != SOCKET_INVALID) {
@ -101,9 +105,15 @@ int server_async_test(int argc, char** argv)
/* declare wolfSSL objects */ /* declare wolfSSL objects */
WOLFSSL_CTX* ctx = NULL; WOLFSSL_CTX* ctx = NULL;
WOLFSSL* ssl = NULL; WOLFSSL* ssl = NULL;
#ifdef HAVE_SIGNAL
sighandler_t sigRet = 0;
#endif
#ifdef HAVE_SIGNAL #ifdef HAVE_SIGNAL
signal(SIGINT, sig_handler); if ((sigRet = signal(SIGINT, sig_handler)) == SIG_ERR) {
fprintf(stderr, "ERROR: failed to listen to SIGINT (errno: %d)\n",errno);
goto exit;
}
#endif #endif
/* Initialize the server address struct with zeros */ /* Initialize the server address struct with zeros */
@ -125,11 +135,17 @@ int server_async_test(int argc, char** argv)
/* make sure server is setup for reuse addr/port */ /* make sure server is setup for reuse addr/port */
on = 1; on = 1;
setsockopt(mSockfd, SOL_SOCKET, SO_REUSEADDR, if (setsockopt(mSockfd, SOL_SOCKET, SO_REUSEADDR,
(char*)&on, (socklen_t)sizeof(on)); (char*)&on, (socklen_t)sizeof(on)) != 0) {
fprintf(stderr, "ERROR: failed to set SO_REUSEADDR (errno: %d)\n",errno);
goto exit;
}
#ifdef SO_REUSEPORT #ifdef SO_REUSEPORT
setsockopt(mSockfd, SOL_SOCKET, SO_REUSEPORT, if (setsockopt(mSockfd, SOL_SOCKET, SO_REUSEPORT,
(char*)&on, (socklen_t)sizeof(on)); (char*)&on, (socklen_t)sizeof(on)) != 0) {
fprintf(stderr, "ERROR: failed to set SO_REUSEPORT (errno: %d)\n",errno);
goto exit;
}
#endif #endif
/* Bind the server socket to our port */ /* Bind the server socket to our port */