From d37e566d5df861e559a200bc8b31a75cdf57d342 Mon Sep 17 00:00:00 2001 From: Ruby Martin Date: Wed, 22 Jan 2025 09:27:21 -0700 Subject: [PATCH 1/6] msys2 build file --- .github/workflows/msys2.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/msys2.yml diff --git a/.github/workflows/msys2.yml b/.github/workflows/msys2.yml new file mode 100644 index 000000000..5f38bbc00 --- /dev/null +++ b/.github/workflows/msys2.yml @@ -0,0 +1,35 @@ +name: MSYS2 Build Test + +# START OF COMMON SECTION +on: + push: + branches: [ 'master', 'main', 'release/**' ] + pull_request: + branches: [ '*' ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +# END OF COMMON SECTION + +jobs: + msys2-ucrt64: + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + steps: + - uses: actions/checkout@v3 + - uses: msys2/setup-msys2@v2 + with: + path: wolfssl + msystem: UCRT64 + update: true + install: git mingw-w64-ucrt-x86_64-gcc autotools base-devel autoconf + - name: configure wolfSSL + run: ./autogen.sh && ./configure --enable-all --disable-crl-monitor + - name: build wolfSSL + run: make check + - name: Display log + if: always() + run: cat test-suite.log From 57646a88ff47593ebbf15b9a0e7796da9de053cd Mon Sep 17 00:00:00 2001 From: Ruby Martin Date: Tue, 28 Jan 2025 13:45:07 -0700 Subject: [PATCH 2/6] check if clientfd != SOCKET_INVALID not 0, add check if USE_WINDOWS_API not defined --- scripts/ocsp-stapling.test | 2 ++ tests/api.c | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/scripts/ocsp-stapling.test b/scripts/ocsp-stapling.test index 8065ac2c6..3d8ecdbc9 100755 --- a/scripts/ocsp-stapling.test +++ b/scripts/ocsp-stapling.test @@ -452,6 +452,8 @@ generate_port() { port=$(($(od -An -N2 /dev/urandom) % (65535-49512) + 49512)) elif [[ "$OSTYPE" == "darwin"* ]]; then port=$(($(od -An -N2 /dev/random) % (65535-49512) + 49512)) + elif [[ "$OSTYPE" == "msys" ]]; then + port=$(($(od -An -N2 /dev/random) % (65535-49512) + 49512)) else echo "Unknown OS TYPE" exit 1 diff --git a/tests/api.c b/tests/api.c index 3d8024447..feac804ba 100644 --- a/tests/api.c +++ b/tests/api.c @@ -8237,7 +8237,7 @@ done: if (!sharedCtx) wolfSSL_CTX_free(ctx); - if (clientfd >= 0) + if (clientfd != SOCKET_INVALID) CloseSocket(clientfd); #ifdef WOLFSSL_TIRTOS @@ -69604,7 +69604,7 @@ static int test_wolfSSL_TXT_DB(void) /* Test index */ ExpectIntEQ(TXT_DB_create_index(db, 3, NULL, - (wolf_sk_hash_cb)(long unsigned int)TXT_DB_hash, + (wolf_sk_hash_cb)(MESSAGE_TYPE_CAST)TXT_DB_hash, (wolf_lh_compare_cb)TXT_DB_cmp), 1); ExpectNotNull(TXT_DB_get_by_index(db, 3, (WOLFSSL_STRING*)fields)); fields[3] = "12DA"; @@ -83752,10 +83752,10 @@ static void test_wolfSSL_dtls_plaintext_client(WOLFSSL* ssl) AssertIntGE(fd, 0); generateDTLSMsg(ch, sizeof(ch), 20, client_hello, 0); /* Server should ignore this datagram */ - AssertIntEQ(send(fd, ch, sizeof(ch), 0), sizeof(ch)); + AssertIntEQ(send(fd, (MESSAGE_TYPE_CAST)ch, sizeof(ch), 0), sizeof(ch)); generateDTLSMsg(ch, sizeof(ch), 20, client_hello, 10000); /* Server should ignore this datagram */ - AssertIntEQ(send(fd, ch, sizeof(ch), 0), sizeof(ch)); + AssertIntEQ(send(fd, (MESSAGE_TYPE_CAST)ch, sizeof(ch), 0), sizeof(ch)); AssertIntEQ(wolfSSL_write(ssl, msg, sizeof(msg)), sizeof(msg)); AssertIntGT(wolfSSL_read(ssl, reply, sizeof(reply)),0); @@ -83866,7 +83866,7 @@ static void test_wolfSSL_dtls12_fragments_spammer(WOLFSSL* ssl) delay.tv_nsec = 10000000; /* wait 0.01 seconds */ c32toa(seq_number, b + seq_offset); c16toa(msg_number, b + msg_offset); - ret = (int)send(fd, b, 55, 0); + ret = (int)send(fd, (MESSAGE_TYPE_CAST)b, 55, 0); nanosleep(&delay, NULL); } } @@ -83986,7 +83986,7 @@ static void test_wolfSSL_dtls_send_alert(WOLFSSL* ssl) fd = wolfSSL_get_wfd(ssl); AssertIntGE(fd, 0); - ret = (int)send(fd, alert_msg, sizeof(alert_msg), 0); + ret = (int)send(fd, (MESSAGE_TYPE_CAST)alert_msg, sizeof(alert_msg), 0); AssertIntGT(ret, 0); } @@ -84057,7 +84057,7 @@ static void test_wolfSSL_send_bad_record(WOLFSSL* ssl) fd = wolfSSL_get_wfd(ssl); AssertIntGE(fd, 0); - ret = (int)send(fd, bad_msg, sizeof(bad_msg), 0); + ret = (int)send(fd, (MESSAGE_TYPE_CAST)bad_msg, sizeof(bad_msg), 0); AssertIntEQ(ret, sizeof(bad_msg)); ret = wolfSSL_write(ssl, "badrecordtest", sizeof("badrecordtest")); AssertIntEQ(ret, sizeof("badrecordtest")); @@ -84415,10 +84415,10 @@ static void test_wolfSSL_dtls_send_ch(WOLFSSL* ssl) fd = wolfSSL_get_wfd(ssl); AssertIntGE(fd, 0); - ret = (int)send(fd, ch_msg, sizeof(ch_msg), 0); + ret = (int)send(fd, (MESSAGE_TYPE_CAST)ch_msg, sizeof(ch_msg), 0); AssertIntGT(ret, 0); /* consume the HRR otherwise handshake will fail */ - ret = (int)recv(fd, ch_msg, sizeof(ch_msg), 0); + ret = (int)recv(fd, (MESSAGE_TYPE_CAST)ch_msg, sizeof(ch_msg), 0); AssertIntGT(ret, 0); } @@ -91064,7 +91064,8 @@ static int test_dtls_msg_from_other_peer(void) * !defined(SINGLE_THREADED) && !defined(NO_RSA) */ #if defined(WOLFSSL_DTLS) && !defined(WOLFSSL_IPV6) && \ !defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER) && \ - defined(HAVE_IO_TESTS_DEPENDENCIES) && !defined(WOLFSSL_NO_TLS12) + defined(HAVE_IO_TESTS_DEPENDENCIES) && !defined(WOLFSSL_NO_TLS12) \ + && !defined(USE_WINDOWS_API) static int test_dtls_ipv6_check(void) { EXPECT_DECLS; From 6fed2fe4475e3e55f474ad6c973abe070eea3ce4 Mon Sep 17 00:00:00 2001 From: Ruby Martin Date: Wed, 29 Jan 2025 14:05:58 -0700 Subject: [PATCH 3/6] include cygwin and msys2 ostypes to oscp-stapling tests --- scripts/ocsp-stapling.test | 5 ++--- scripts/ocsp-stapling2.test | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/ocsp-stapling.test b/scripts/ocsp-stapling.test index 3d8ecdbc9..2d544da1b 100755 --- a/scripts/ocsp-stapling.test +++ b/scripts/ocsp-stapling.test @@ -448,12 +448,11 @@ generate_port() { # Generate a random port number #-------------------------------------------------------------------------# - if [[ "$OSTYPE" == "linux"* ]]; then + if [[ "$OSTYPE" == "linux"* || "$OSTYPE" == "msys" + || "$OSTYPE" == "cygwin"* ]]; then port=$(($(od -An -N2 /dev/urandom) % (65535-49512) + 49512)) elif [[ "$OSTYPE" == "darwin"* ]]; then port=$(($(od -An -N2 /dev/random) % (65535-49512) + 49512)) - elif [[ "$OSTYPE" == "msys" ]]; then - port=$(($(od -An -N2 /dev/random) % (65535-49512) + 49512)) else echo "Unknown OS TYPE" exit 1 diff --git a/scripts/ocsp-stapling2.test b/scripts/ocsp-stapling2.test index dea1af61b..4ce8729d3 100755 --- a/scripts/ocsp-stapling2.test +++ b/scripts/ocsp-stapling2.test @@ -467,7 +467,8 @@ generate_port() { # Generate a random port number #-------------------------------------------------------------------------# - if [[ "$OSTYPE" == "linux"* ]]; then + if [[ "$OSTYPE" == "linux"* || "$OSTYPE" == "msys" + || "$OSTYPE" == "cygwin" ]]; then port=$(($(od -An -N2 /dev/urandom) % (65535-49512) + 49512)) elif [[ "$OSTYPE" == "darwin"* ]]; then port=$(($(od -An -N2 /dev/random) % (65535-49512) + 49512)) From 439012dd5761d89871ec006a6afa068a15b71f91 Mon Sep 17 00:00:00 2001 From: Ruby Martin Date: Tue, 11 Feb 2025 14:39:53 -0700 Subject: [PATCH 4/6] adjust xfopen commands --- tests/api.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/api.c b/tests/api.c index feac804ba..3f1f787b0 100644 --- a/tests/api.c +++ b/tests/api.c @@ -57706,7 +57706,7 @@ static int test_wolfSSL_BIO(void) ExpectIntEQ((int)BIO_set_mem_eof_return(f_bio1, -1), 0); ExpectIntEQ((int)BIO_set_mem_eof_return(NULL, -1), 0); - ExpectTrue((f1 = XFOPEN(svrCertFile, "rwb")) != XBADFILE); + ExpectTrue((f1 = XFOPEN(svrCertFile, "rb+")) != XBADFILE); ExpectIntEQ((int)BIO_set_fp(f_bio1, f1, BIO_CLOSE), WOLFSSL_SUCCESS); ExpectIntEQ(BIO_write_filename(f_bio2, testFile), WOLFSSL_SUCCESS); @@ -57730,7 +57730,7 @@ static int test_wolfSSL_BIO(void) BIO_free(f_bio2); f_bio2 = NULL; - ExpectNotNull(f_bio1 = BIO_new_file(svrCertFile, "rwb")); + ExpectNotNull(f_bio1 = BIO_new_file(svrCertFile, "rb+")); ExpectIntEQ((int)BIO_set_mem_eof_return(f_bio1, -1), 0); ExpectIntEQ(BIO_read(f_bio1, cert, sizeof(cert)), sizeof(cert)); BIO_free(f_bio1); @@ -60382,7 +60382,7 @@ static int test_wc_ERR_print_errors_fp(void) XFILE fp = XBADFILE; WOLFSSL_ERROR(WC_NO_ERR_TRACE(BAD_FUNC_ARG)); - ExpectTrue((fp = XFOPEN("./tests/test-log-dump-to-file.txt", "ar")) != + ExpectTrue((fp = XFOPEN("./tests/test-log-dump-to-file.txt", "a+")) != XBADFILE); wc_ERR_print_errors_fp(fp); #if defined(DEBUG_WOLFSSL) From 0c413e75c68b3bafd76fecce4be082fcd7bb7e34 Mon Sep 17 00:00:00 2001 From: Ruby Martin Date: Mon, 17 Feb 2025 11:37:28 -0700 Subject: [PATCH 5/6] add environment matrix to msys workflow --- .github/workflows/msys2.yml | 16 +++++++++++----- tests/api.c | 16 ++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/workflows/msys2.yml b/.github/workflows/msys2.yml index 5f38bbc00..266487ae9 100644 --- a/.github/workflows/msys2.yml +++ b/.github/workflows/msys2.yml @@ -13,21 +13,27 @@ concurrency: # END OF COMMON SECTION jobs: - msys2-ucrt64: + msys2: runs-on: windows-latest defaults: run: shell: msys2 {0} + strategy: + fail-fast: false + matrix: + include: + - { sys: ucrt64, compiler: mingw-w64-ucrt-x86_64-gcc } + - { sys: mingw64, compiler: mingw-w64-x86_64-gcc } + - { sys: msys, compiler: gcc } steps: - uses: actions/checkout@v3 - uses: msys2/setup-msys2@v2 with: - path: wolfssl - msystem: UCRT64 + msystem: ${{ matrix.sys }} update: true - install: git mingw-w64-ucrt-x86_64-gcc autotools base-devel autoconf + install: git ${{matrix.compiler}} autotools base-devel autoconf netcat - name: configure wolfSSL - run: ./autogen.sh && ./configure --enable-all --disable-crl-monitor + run: ./autogen.sh && ./configure CFLAGS="-DUSE_CERT_BUFFERS_2048 -DUSE_CERT_BUFFERS_256" - name: build wolfSSL run: make check - name: Display log diff --git a/tests/api.c b/tests/api.c index 3f1f787b0..47d9e27f9 100644 --- a/tests/api.c +++ b/tests/api.c @@ -69604,7 +69604,7 @@ static int test_wolfSSL_TXT_DB(void) /* Test index */ ExpectIntEQ(TXT_DB_create_index(db, 3, NULL, - (wolf_sk_hash_cb)(MESSAGE_TYPE_CAST)TXT_DB_hash, + (wolf_sk_hash_cb)(long unsigned int)TXT_DB_hash, (wolf_lh_compare_cb)TXT_DB_cmp), 1); ExpectNotNull(TXT_DB_get_by_index(db, 3, (WOLFSSL_STRING*)fields)); fields[3] = "12DA"; @@ -83752,10 +83752,10 @@ static void test_wolfSSL_dtls_plaintext_client(WOLFSSL* ssl) AssertIntGE(fd, 0); generateDTLSMsg(ch, sizeof(ch), 20, client_hello, 0); /* Server should ignore this datagram */ - AssertIntEQ(send(fd, (MESSAGE_TYPE_CAST)ch, sizeof(ch), 0), sizeof(ch)); + AssertIntEQ(send(fd, ch, sizeof(ch), 0), sizeof(ch)); generateDTLSMsg(ch, sizeof(ch), 20, client_hello, 10000); /* Server should ignore this datagram */ - AssertIntEQ(send(fd, (MESSAGE_TYPE_CAST)ch, sizeof(ch), 0), sizeof(ch)); + AssertIntEQ(send(fd, ch, sizeof(ch), 0), sizeof(ch)); AssertIntEQ(wolfSSL_write(ssl, msg, sizeof(msg)), sizeof(msg)); AssertIntGT(wolfSSL_read(ssl, reply, sizeof(reply)),0); @@ -83866,7 +83866,7 @@ static void test_wolfSSL_dtls12_fragments_spammer(WOLFSSL* ssl) delay.tv_nsec = 10000000; /* wait 0.01 seconds */ c32toa(seq_number, b + seq_offset); c16toa(msg_number, b + msg_offset); - ret = (int)send(fd, (MESSAGE_TYPE_CAST)b, 55, 0); + ret = (int)send(fd, b, 55, 0); nanosleep(&delay, NULL); } } @@ -83986,7 +83986,7 @@ static void test_wolfSSL_dtls_send_alert(WOLFSSL* ssl) fd = wolfSSL_get_wfd(ssl); AssertIntGE(fd, 0); - ret = (int)send(fd, (MESSAGE_TYPE_CAST)alert_msg, sizeof(alert_msg), 0); + ret = (int)send(fd, alert_msg, sizeof(alert_msg), 0); AssertIntGT(ret, 0); } @@ -84057,7 +84057,7 @@ static void test_wolfSSL_send_bad_record(WOLFSSL* ssl) fd = wolfSSL_get_wfd(ssl); AssertIntGE(fd, 0); - ret = (int)send(fd, (MESSAGE_TYPE_CAST)bad_msg, sizeof(bad_msg), 0); + ret = (int)send(fd, bad_msg, sizeof(bad_msg), 0); AssertIntEQ(ret, sizeof(bad_msg)); ret = wolfSSL_write(ssl, "badrecordtest", sizeof("badrecordtest")); AssertIntEQ(ret, sizeof("badrecordtest")); @@ -84415,10 +84415,10 @@ static void test_wolfSSL_dtls_send_ch(WOLFSSL* ssl) fd = wolfSSL_get_wfd(ssl); AssertIntGE(fd, 0); - ret = (int)send(fd, (MESSAGE_TYPE_CAST)ch_msg, sizeof(ch_msg), 0); + ret = (int)send(fd, ch_msg, sizeof(ch_msg), 0); AssertIntGT(ret, 0); /* consume the HRR otherwise handshake will fail */ - ret = (int)recv(fd, (MESSAGE_TYPE_CAST)ch_msg, sizeof(ch_msg), 0); + ret = (int)recv(fd, ch_msg, sizeof(ch_msg), 0); AssertIntGT(ret, 0); } From b64f509d1b683843a330a4c9473304475a01c24e Mon Sep 17 00:00:00 2001 From: Ruby Martin Date: Wed, 26 Feb 2025 09:17:09 -0700 Subject: [PATCH 6/6] define NO_WRITE_TEMP_FILES --- .github/workflows/msys2.yml | 2 +- scripts/ocsp-stapling2.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/msys2.yml b/.github/workflows/msys2.yml index 266487ae9..0641a3104 100644 --- a/.github/workflows/msys2.yml +++ b/.github/workflows/msys2.yml @@ -33,7 +33,7 @@ jobs: update: true install: git ${{matrix.compiler}} autotools base-devel autoconf netcat - name: configure wolfSSL - run: ./autogen.sh && ./configure CFLAGS="-DUSE_CERT_BUFFERS_2048 -DUSE_CERT_BUFFERS_256" + run: ./autogen.sh && ./configure CFLAGS="-DUSE_CERT_BUFFERS_2048 -DUSE_CERT_BUFFERS_256 -DNO_WRITE_TEMP_FILES" - name: build wolfSSL run: make check - name: Display log diff --git a/scripts/ocsp-stapling2.test b/scripts/ocsp-stapling2.test index 4ce8729d3..c5664b37a 100755 --- a/scripts/ocsp-stapling2.test +++ b/scripts/ocsp-stapling2.test @@ -467,7 +467,7 @@ generate_port() { # Generate a random port number #-------------------------------------------------------------------------# - if [[ "$OSTYPE" == "linux"* || "$OSTYPE" == "msys" + if [[ "$OSTYPE" == "linux"* || "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then port=$(($(od -An -N2 /dev/urandom) % (65535-49512) + 49512)) elif [[ "$OSTYPE" == "darwin"* ]]; then