Skip to content

Commit 8e3b335

Browse files
author
Ruby Martin
committed
api.c message type cast
1 parent 04d342e commit 8e3b335

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

tests/api.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,11 @@ int test_memio_setup(struct test_memio_ctx *ctx,
830830
}
831831
#endif
832832

833+
#ifdef USE_WINDOWS_API
834+
#define MESSAGE_TYPE_CAST char*
835+
#else
836+
#define MESSAGE_TYPE_CAST void*
837+
#endif
833838
/*----------------------------------------------------------------------------*
834839
| BIO with fixed read/write size
835840
*----------------------------------------------------------------------------*/
@@ -8389,7 +8394,7 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_loop(void* args)
83898394
if (!sharedCtx)
83908395
wolfSSL_CTX_free(ctx);
83918396

8392-
if (clientfd >= 0)
8397+
if (clientfd != SOCKET_INVALID)
83938398
CloseSocket(clientfd);
83948399

83958400
#ifdef WOLFSSL_TIRTOS
@@ -76214,7 +76219,7 @@ static int test_wolfSSL_TXT_DB(void)
7621476219

7621576220
/* Test index */
7621676221
ExpectIntEQ(TXT_DB_create_index(db, 3, NULL,
76217-
(wolf_sk_hash_cb)(long unsigned int)TXT_DB_hash,
76222+
(wolf_sk_hash_cb)TXT_DB_hash,
7621876223
(wolf_lh_compare_cb)TXT_DB_cmp), 1);
7621976224
ExpectNotNull(TXT_DB_get_by_index(db, 3, (WOLFSSL_STRING*)fields));
7622076225
fields[3] = "12DA";
@@ -90343,10 +90348,10 @@ static void test_wolfSSL_dtls_plaintext_client(WOLFSSL* ssl)
9034390348
AssertIntGE(fd, 0);
9034490349
generateDTLSMsg(ch, sizeof(ch), 20, client_hello, 0);
9034590350
/* Server should ignore this datagram */
90346-
AssertIntEQ(send(fd, ch, sizeof(ch), 0), sizeof(ch));
90351+
AssertIntEQ(send(fd, (MESSAGE_TYPE_CAST)ch, sizeof(ch), 0), sizeof(ch));
9034790352
generateDTLSMsg(ch, sizeof(ch), 20, client_hello, 10000);
9034890353
/* Server should ignore this datagram */
90349-
AssertIntEQ(send(fd, ch, sizeof(ch), 0), sizeof(ch));
90354+
AssertIntEQ(send(fd, (MESSAGE_TYPE_CAST)ch, sizeof(ch), 0), sizeof(ch));
9035090355

9035190356
AssertIntEQ(wolfSSL_write(ssl, msg, sizeof(msg)), sizeof(msg));
9035290357
AssertIntGT(wolfSSL_read(ssl, reply, sizeof(reply)),0);
@@ -90457,7 +90462,7 @@ static void test_wolfSSL_dtls12_fragments_spammer(WOLFSSL* ssl)
9045790462
delay.tv_nsec = 10000000; /* wait 0.01 seconds */
9045890463
c32toa(seq_number, b + seq_offset);
9045990464
c16toa(msg_number, b + msg_offset);
90460-
ret = (int)send(fd, b, 55, 0);
90465+
ret = (int)send(fd, (MESSAGE_TYPE_CAST)b, 55, 0);
9046190466
nanosleep(&delay, NULL);
9046290467
}
9046390468
}
@@ -90502,7 +90507,7 @@ static void test_wolfSSL_dtls13_fragments_spammer(WOLFSSL* ssl)
9050290507
c16toa(msg_number, b + msg_offset);
9050390508
sendSz = BuildTls13Message(ssl, sendBuf, sendSz, b,
9050490509
(int)idx, handshake, 0, 0, 0);
90505-
ret = (int)send(fd, sendBuf, (size_t)sendSz, 0);
90510+
ret = (int)send(fd, (MESSAGE_TYPE_CAST)sendBuf, (size_t)sendSz, 0);
9050690511
nanosleep(&delay, NULL);
9050790512
}
9050890513
}
@@ -90576,7 +90581,7 @@ static void test_wolfSSL_dtls_send_alert(WOLFSSL* ssl)
9057690581

9057790582
fd = wolfSSL_get_wfd(ssl);
9057890583
AssertIntGE(fd, 0);
90579-
ret = (int)send(fd, alert_msg, sizeof(alert_msg), 0);
90584+
ret = (int)send(fd, (MESSAGE_TYPE_CAST)alert_msg, sizeof(alert_msg), 0);
9058090585
AssertIntGT(ret, 0);
9058190586
}
9058290587

@@ -90647,7 +90652,7 @@ static void test_wolfSSL_send_bad_record(WOLFSSL* ssl)
9064790652

9064890653
fd = wolfSSL_get_wfd(ssl);
9064990654
AssertIntGE(fd, 0);
90650-
ret = (int)send(fd, bad_msg, sizeof(bad_msg), 0);
90655+
ret = (int)send(fd, (MESSAGE_TYPE_CAST)bad_msg, sizeof(bad_msg), 0);
9065190656
AssertIntEQ(ret, sizeof(bad_msg));
9065290657
ret = wolfSSL_write(ssl, "badrecordtest", sizeof("badrecordtest"));
9065390658
AssertIntEQ(ret, sizeof("badrecordtest"));
@@ -90728,7 +90733,7 @@ static byte test_AEAD_done = 0;
9072890733

9072990734
static int test_AEAD_cbiorecv(WOLFSSL *ssl, char *buf, int sz, void *ctx)
9073090735
{
90731-
int ret = (int)recv(wolfSSL_get_fd(ssl), buf, sz, 0);
90736+
int ret = (int)recv(wolfSSL_get_fd(ssl), (MESSAGE_TYPE_CAST)buf, sz, 0);
9073290737
if (ret > 0) {
9073390738
if (test_AEAD_fail_decryption) {
9073490739
/* Modify the packet to trigger a decryption failure */
@@ -90974,10 +90979,10 @@ static void test_wolfSSL_dtls_send_ch(WOLFSSL* ssl)
9097490979

9097590980
fd = wolfSSL_get_wfd(ssl);
9097690981
AssertIntGE(fd, 0);
90977-
ret = (int)send(fd, ch_msg, sizeof(ch_msg), 0);
90982+
ret = (int)send(fd, (MESSAGE_TYPE_CAST)ch_msg, sizeof(ch_msg), 0);
9097890983
AssertIntGT(ret, 0);
9097990984
/* consume the HRR otherwise handshake will fail */
90980-
ret = (int)recv(fd, ch_msg, sizeof(ch_msg), 0);
90985+
ret = (int)recv(fd, (MESSAGE_TYPE_CAST)ch_msg, sizeof(ch_msg), 0);
9098190986
AssertIntGT(ret, 0);
9098290987
}
9098390988

@@ -91045,10 +91050,10 @@ static void test_wolfSSL_dtls_send_ch_with_invalid_cookie(WOLFSSL* ssl)
9104591050
};
9104691051

9104791052
fd = wolfSSL_get_wfd(ssl);
91048-
ret = (int)send(fd, ch_msh_invalid_cookie, sizeof(ch_msh_invalid_cookie), 0);
91053+
ret = (int)send(fd, (MESSAGE_TYPE_CAST)ch_msh_invalid_cookie, sizeof(ch_msh_invalid_cookie), 0);
9104991054
AssertIntGT(ret, 0);
9105091055
/* should reply with an illegal_parameter reply */
91051-
ret = (int)recv(fd, alert_reply, sizeof(alert_reply), 0);
91056+
ret = (int)recv(fd, (MESSAGE_TYPE_CAST)alert_reply, sizeof(alert_reply), 0);
9105291057
AssertIntEQ(ret, sizeof(expected_alert_reply));
9105391058
AssertIntEQ(XMEMCMP(alert_reply, expected_alert_reply, sizeof(expected_alert_reply)), 0);
9105491059
}
@@ -97619,7 +97624,8 @@ static int test_dtls_msg_from_other_peer(void)
9761997624
* !defined(SINGLE_THREADED) && !defined(NO_RSA) */
9762097625
#if defined(WOLFSSL_DTLS) && !defined(WOLFSSL_IPV6) && \
9762197626
!defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER) && \
97622-
defined(HAVE_IO_TESTS_DEPENDENCIES) && !defined(WOLFSSL_NO_TLS12)
97627+
defined(HAVE_IO_TESTS_DEPENDENCIES) && !defined(WOLFSSL_NO_TLS12) \
97628+
&& !defined(USE_WINDOWS_API)
9762397629
static int test_dtls_ipv6_check(void)
9762497630
{
9762597631
EXPECT_DECLS;

0 commit comments

Comments
 (0)