From 6a90f4cda8e16de7ab7f818d4254d33dea3be751 Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Wed, 29 Nov 2023 10:54:47 -0800 Subject: [PATCH 01/31] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07051ff085..a5e1fc6143 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,8 +51,8 @@ jobs: mac-os-build-gcc: runs-on: macos-11 env: - CC: gcc - CXX: g++ + CC: /usr/local/bin/gcc-13 + CXX: /usr/local/bin/g++-13 AWS_KVS_LOG_LEVEL: 2 permissions: id-token: write From 50914190b7a291514fa092090822c98ed9c535c9 Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Wed, 29 Nov 2023 13:08:58 -0800 Subject: [PATCH 02/31] Remove pedantic errors from compile options --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e7bed88e4b..7b8ebbfc2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -446,8 +446,8 @@ if (WIN32) endif() if(COMPILER_WARNINGS) - target_compile_options(kvsWebrtcClient PUBLIC -Wall -Werror -pedantic -Wextra -Wno-unknown-warning-option) - target_compile_options(kvsWebrtcSignalingClient PUBLIC -Wall -Werror -pedantic -Wextra -Wno-unknown-warning-option) + target_compile_options(kvsWebrtcClient PUBLIC -Wall -Werror -Wextra -Wno-unknown-warning-option) + target_compile_options(kvsWebrtcSignalingClient PUBLIC -Wall -Werror -Wextra -Wno-unknown-warning-option) endif() install(TARGETS kvsWebrtcClient kvsWebrtcSignalingClient From 09eddd182e08a9495a6143645a4093386ac69817 Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Wed, 29 Nov 2023 13:15:18 -0800 Subject: [PATCH 03/31] Add -Wpedantic --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b8ebbfc2e..8cc332d1ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -446,8 +446,8 @@ if (WIN32) endif() if(COMPILER_WARNINGS) - target_compile_options(kvsWebrtcClient PUBLIC -Wall -Werror -Wextra -Wno-unknown-warning-option) - target_compile_options(kvsWebrtcSignalingClient PUBLIC -Wall -Werror -Wextra -Wno-unknown-warning-option) + target_compile_options(kvsWebrtcClient PUBLIC -Wall -Werror -Wpedantic -Wextra -Wno-unknown-warning-option) + target_compile_options(kvsWebrtcSignalingClient PUBLIC -Wall -Werror -Wpedantic -Wextra -Wno-unknown-warning-option) endif() install(TARGETS kvsWebrtcClient kvsWebrtcSignalingClient From d62fdd6be814cd3b245a797ee8e76dfc5d7e132a Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Wed, 29 Nov 2023 13:44:54 -0800 Subject: [PATCH 04/31] add -Wno-error=pedantic --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cc332d1ee..a0418fd686 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -446,8 +446,8 @@ if (WIN32) endif() if(COMPILER_WARNINGS) - target_compile_options(kvsWebrtcClient PUBLIC -Wall -Werror -Wpedantic -Wextra -Wno-unknown-warning-option) - target_compile_options(kvsWebrtcSignalingClient PUBLIC -Wall -Werror -Wpedantic -Wextra -Wno-unknown-warning-option) + target_compile_options(kvsWebrtcClient PUBLIC -Wall -Werror -pedantic -Wextra -Wno-unknown-warning-option -Wno-error=pedantic) + target_compile_options(kvsWebrtcSignalingClient PUBLIC -Wall -Werror -pedantic -Wextra -Wno-unknown-warning-option -Wno-error=pedantic) endif() install(TARGETS kvsWebrtcClient kvsWebrtcSignalingClient From 7db983f500797542e8ee1e6b31305909431384a3 Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Wed, 29 Nov 2023 15:14:27 -0800 Subject: [PATCH 05/31] remove pedantic --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0418fd686..7b8ebbfc2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -446,8 +446,8 @@ if (WIN32) endif() if(COMPILER_WARNINGS) - target_compile_options(kvsWebrtcClient PUBLIC -Wall -Werror -pedantic -Wextra -Wno-unknown-warning-option -Wno-error=pedantic) - target_compile_options(kvsWebrtcSignalingClient PUBLIC -Wall -Werror -pedantic -Wextra -Wno-unknown-warning-option -Wno-error=pedantic) + target_compile_options(kvsWebrtcClient PUBLIC -Wall -Werror -Wextra -Wno-unknown-warning-option) + target_compile_options(kvsWebrtcSignalingClient PUBLIC -Wall -Werror -Wextra -Wno-unknown-warning-option) endif() install(TARGETS kvsWebrtcClient kvsWebrtcSignalingClient From ca1025fa961f8a764e4b0507d8b1a3c66d8e319a Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Wed, 6 Dec 2023 01:51:40 -0800 Subject: [PATCH 06/31] Add SYSTEM to suppress dependency gcc warnings --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b8ebbfc2e..97decb4acf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -385,8 +385,9 @@ endif() file(GLOB WEBRTC_SIGNALING_CLIENT_SOURCE_FILES "src/source/Signaling/*.c") -include_directories(${OPEN_SRC_INCLUDE_DIRS}) -include_directories(${OPEN_SRC_INSTALL_PREFIX}/include) + +include_directories(SYSTEM ${OPEN_SRC_INCLUDE_DIRS}) +include_directories(SYSTEM ${OPEN_SRC_INSTALL_PREFIX}/include) include_directories(${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}/src/include) # include sdp_config.h include_directories(src/source/Sdp/kvssdp) From 0ed7f1eb716b24b3172b8824c24aa10d1e96a695 Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Wed, 6 Dec 2023 02:26:27 -0800 Subject: [PATCH 07/31] Check wBioDataLen negative as a long instead of uint --- src/source/Crypto/Tls_openssl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/source/Crypto/Tls_openssl.c b/src/source/Crypto/Tls_openssl.c index 207d4c5dae..0d2775a346 100644 --- a/src/source/Crypto/Tls_openssl.c +++ b/src/source/Crypto/Tls_openssl.c @@ -188,6 +188,7 @@ STATUS tlsSessionPutApplicationData(PTlsSession pTlsSession, PBYTE pData, UINT32 SIZE_T wBioDataLen = 0; PCHAR wBioBuffer = NULL; + LONG wBioGetMemDataRet = 0; CHK(pTlsSession != NULL, STATUS_NULL_ARG); @@ -212,8 +213,9 @@ STATUS tlsSessionPutApplicationData(PTlsSession pTlsSession, PBYTE pData, UINT32 } } - wBioDataLen = (SIZE_T) BIO_get_mem_data(SSL_get_wbio(pTlsSession->pSsl), &wBioBuffer); - CHK_ERR(wBioDataLen >= 0, STATUS_SEND_DATA_FAILED, "BIO_get_mem_data failed"); + wBioGetMemDataRet = BIO_get_mem_data(SSL_get_wbio(pTlsSession->pSsl), &wBioBuffer); + CHK_ERR(wBioGetMemDataRet >= 0, STATUS_SEND_DATA_FAILED, "BIO_get_mem_data failed"); + wBioDataLen = (SIZE_T) wBioGetMemDataRet; if (wBioDataLen > 0) { retStatus = From cc75751ffead6d5115357a2b737d2d22524ffc05 Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Wed, 6 Dec 2023 13:02:27 -0800 Subject: [PATCH 08/31] Fix explicit fall-through comment to be caught by gcc --- src/source/Ice/IceAgent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/source/Ice/IceAgent.c b/src/source/Ice/IceAgent.c index b0dfd05e35..c3725de2f9 100644 --- a/src/source/Ice/IceAgent.c +++ b/src/source/Ice/IceAgent.c @@ -1580,7 +1580,7 @@ STATUS iceAgentCheckCandidatePairConnection(PIceAgent pIceAgent) switch (pIceCandidatePair->state) { case ICE_CANDIDATE_PAIR_STATE_WAITING: pIceCandidatePair->state = ICE_CANDIDATE_PAIR_STATE_IN_PROGRESS; - // NOTE: Explicit fall-through + // explicit fall-through case ICE_CANDIDATE_PAIR_STATE_IN_PROGRESS: CHK_STATUS(iceCandidatePairCheckConnection(pIceAgent->pBindingRequest, pIceAgent, pIceCandidatePair)); break; From de912e0152ddd97a6c8edc69c5786d8243ecbcd8 Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Wed, 6 Dec 2023 13:20:34 -0800 Subject: [PATCH 09/31] Trying new fall-through comment --- src/source/Ice/IceAgent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/source/Ice/IceAgent.c b/src/source/Ice/IceAgent.c index c3725de2f9..457f2eebf1 100644 --- a/src/source/Ice/IceAgent.c +++ b/src/source/Ice/IceAgent.c @@ -1580,7 +1580,7 @@ STATUS iceAgentCheckCandidatePairConnection(PIceAgent pIceAgent) switch (pIceCandidatePair->state) { case ICE_CANDIDATE_PAIR_STATE_WAITING: pIceCandidatePair->state = ICE_CANDIDATE_PAIR_STATE_IN_PROGRESS; - // explicit fall-through + /* FALLTHRU */ case ICE_CANDIDATE_PAIR_STATE_IN_PROGRESS: CHK_STATUS(iceCandidatePairCheckConnection(pIceAgent->pBindingRequest, pIceAgent, pIceCandidatePair)); break; From ae0a3b0e1babe403f7c0911f46dc6da699093271 Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Wed, 6 Dec 2023 13:21:48 -0800 Subject: [PATCH 10/31] Isolating mac builds for testing --- .github/workflows/ci.yml | 371 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 361 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5e1fc6143..9d96b62adf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -197,21 +197,358 @@ jobs: # memory-sanitizer: # runs-on: ubuntu-18.04 # env: - # CC: clang-7 - # CXX: clang++-7 # AWS_KVS_LOG_LEVEL: 2 + # permissions: + # id-token: write + # contents: read + # steps: + # - name: Clone repository + # uses: actions/checkout@v3 + # - name: Configure AWS Credentials + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + # aws-region: ${{ secrets.AWS_REGION }} + # - name: Build repository + # run: | + # brew unlink openssl + # mkdir build && cd build + # sh -c 'cmake .. -DCMAKE_C_COMPILER=$(brew --prefix llvm@15)/bin/clang -DCMAKE_CXX_COMPILER=$(brew --prefix llvm@15)/bin/clang++;cmake .. -DCMAKE_C_COMPILER=$(brew --prefix llvm@15)/bin/clang -DCMAKE_CXX_COMPILER=$(brew --prefix llvm@15)/bin/clang++' + # make + # static-build-mac: + # runs-on: macos-11 + # env: + # AWS_KVS_LOG_LEVEL: 2 + # LDFLAGS: -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib + # CPATH: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ + # permissions: + # id-token: write + # contents: read + # steps: + # - name: Clone repository + # uses: actions/checkout@v3 + # - name: Configure AWS Credentials + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + # aws-region: ${{ secrets.AWS_REGION }} + # - name: Build repository + # run: | + # mkdir build && cd build + # cmake .. -DBUILD_STATIC_LIBS=TRUE -DBUILD_TEST=TRUE + # make + # - name: Run tests + # run: | + # cd build + # ./tst/webrtc_client_test + # linux-gcc-code-coverage: + # runs-on: ubuntu-20.04 + # env: + # AWS_KVS_LOG_LEVEL: 2 + # permissions: + # id-token: write + # contents: read + # steps: + # - name: Clone repository + # uses: actions/checkout@v3 + # - name: Configure AWS Credentials + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + # aws-region: ${{ secrets.AWS_REGION }} + # - name: Build repository + # run: | + # sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6' + # mkdir build && cd build + # cmake .. -DCODE_COVERAGE=TRUE -DBUILD_TEST=TRUE + # make + # ulimit -c unlimited -S + # - name: Run tests + # run: | + # cd build + # timeout --signal=SIGABRT 60m ./tst/webrtc_client_test + # - name: Code coverage + # run: | + # for test_file in $(find CMakeFiles/kvsWebrtcClient.dir CMakeFiles/kvsWebrtcSignalingClient.dir -name '*.gcno'); do gcov $test_file; done + # bash <(curl -s https://codecov.io/bash) + # address-sanitizer: + # runs-on: ubuntu-20.04 + # env: + # ASAN_OPTIONS: detect_odr_violation=0:detect_leaks=1 + # LSAN_OPTIONS: suppressions=../tst/suppressions/LSAN.supp + # CC: clang + # CXX: clang++ + # AWS_KVS_LOG_LEVEL: 2 + # permissions: + # id-token: write + # contents: read + # steps: + # - name: Clone repository + # uses: actions/checkout@v3 + # - name: Configure AWS Credentials + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + # aws-region: ${{ secrets.AWS_REGION }} + # - name: Install dependencies + # run: | + # sudo apt clean && sudo apt update + # sudo apt-get -y install clang + # - name: Build repository + # run: | + # # TODO: Remove the following line. This is only a workaround for enabling IPv6, https://github.com/travis-ci/travis-ci/issues/8891. + # sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6' + # mkdir build && cd build + # cmake .. -DBUILD_TEST=TRUE -DADDRESS_SANITIZER=TRUE + # make + # ulimit -c unlimited -S + # - name: Run tests + # run: | + # cd build + # timeout --signal=SIGABRT 60m ./tst/webrtc_client_test + # undefined-behavior-sanitizer: + # runs-on: ubuntu-20.04 + # env: + # UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1 + # CC: clang + # CXX: clang++ + # AWS_KVS_LOG_LEVEL: 2 + # permissions: + # id-token: write + # contents: read + # steps: + # - name: Clone repository + # uses: actions/checkout@v3 + # - name: Configure AWS Credentials + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + # aws-region: ${{ secrets.AWS_REGION }} + # - name: Install dependencies + # run: | + # sudo apt clean && sudo apt update + # sudo apt-get -y install clang + # - name: Build repository + # run: | + # # TODO: Remove the following line. This is only a workaround for enabling IPv6, https://github.com/travis-ci/travis-ci/issues/8891. + # sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6' + # mkdir build && cd build + # cmake .. -DBUILD_TEST=TRUE -DUNDEFINED_BEHAVIOR_SANITIZER=TRUE + # make + # ulimit -c unlimited -S + # - name: Run tests + # run: | + # cd build + # timeout --signal=SIGABRT 60m ./tst/webrtc_client_test + # # memory-sanitizer: + # # runs-on: ubuntu-18.04 + # # env: + # # CC: clang-7 + # # CXX: clang++-7 + # # AWS_KVS_LOG_LEVEL: 2 + # # steps: + # # - name: Clone repository + # # uses: actions/checkout@v3 + # # - name: Install dependencies + # # run: | + # # sudo apt clean && sudo apt update + # # sudo apt-get -y install clang-7 + # # - name: Build repository + # # run: | + # # sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6' + # # mkdir build && cd build + # # cmake .. -DMEMORY_SANITIZER=TRUE -DBUILD_TEST=TRUE + # # make + # # ulimit -c unlimited -S + # # timeout --signal=SIGABRT 60m build/tst/webrtc_client_test + # thread-sanitizer: + # runs-on: ubuntu-20.04 + # env: + # TSAN_OPTIONS: second_deadlock_stack=1:halt_on_error=1:suppressions=../tst/suppressions/TSAN.supp + # CC: clang + # CXX: clang++ + # AWS_KVS_LOG_LEVEL: 2 + # permissions: + # id-token: write + # contents: read + # steps: + # - name: Clone repository + # uses: actions/checkout@v3 + # - name: Configure AWS Credentials + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + # aws-region: ${{ secrets.AWS_REGION }} + # - name: Install dependencies + # run: | + # sudo apt clean && sudo apt update + # sudo apt-get -y install clang + # - name: Build repository + # run: | + # sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6' + # mkdir build && cd build + # cmake .. -DBUILD_TEST=TRUE -DTHREAD_SANITIZER=TRUE + # make + # ulimit -c unlimited -S + # - name: Run tests + # run: | + # cd build + # timeout --signal=SIGABRT 60m ./tst/webrtc_client_test + # linux-gcc-4_4: + # runs-on: ubuntu-20.04 + # env: + # AWS_KVS_LOG_LEVEL: 2 + # CC: gcc-4.4 + # permissions: + # id-token: write + # contents: read + # steps: + # - name: Clone repository + # uses: actions/checkout@v3 + # - name: Configure AWS Credentials + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + # aws-region: ${{ secrets.AWS_REGION }} + # - name: Install deps + # run: | + # sudo apt clean && sudo apt update + # sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6' + # sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + # sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ trusty main' + # sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ trusty universe' + # sudo apt-get -q update + # sudo apt-get -y install gcc-4.4 + # sudo apt-get -y install gdb + # - name: Build repository + # run: | + # mkdir build && cd build + # cmake .. -DBUILD_TEST=TRUE + # make + # ulimit -c unlimited -S + # - name: Run tests + # run: | + # cd build + # timeout --signal=SIGABRT 60m ./tst/webrtc_client_test + # static-build-linux: + # runs-on: ubuntu-20.04 + # container: + # image: alpine:3.15.4 + # env: + # CC: gcc + # CXX: g++ + # AWS_KVS_LOG_LEVEL: 2 + # permissions: + # id-token: write + # contents: read # steps: # - name: Clone repository # uses: actions/checkout@v4 # - name: Install dependencies # run: | + # apk update + # apk upgrade + # apk add alpine-sdk cmake clang linux-headers perl bash openssl-dev + # - name: Build Repository + # run: | + # mkdir build && cd build + # cmake .. -DBUILD_STATIC_LIBS=TRUE -DBUILD_TEST=TRUE + # make + # mbedtls-ubuntu-gcc: + # runs-on: ubuntu-20.04 + # env: + # AWS_KVS_LOG_LEVEL: 2 + # permissions: + # id-token: write + # contents: read + # steps: + # - name: Clone repository + # uses: actions/checkout@v3 + # - name: Configure AWS Credentials + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + # aws-region: ${{ secrets.AWS_REGION }} + # - name: Install deps + # run: | + # sudo apt clean && sudo apt update + # sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6' + # sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + # sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ trusty main' + # sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ trusty universe' + # sudo apt-get -q update + # sudo apt-get -y install gcc-4.4 + # sudo apt-get -y install gdb + # - name: Build repository + # run: | + # mkdir build && cd build + # cmake .. -DBUILD_TEST=TRUE -DUSE_OPENSSL=OFF -DUSE_MBEDTLS=ON + # make + # ulimit -c unlimited -S + # - name: Run tests + # run: | + # cd build + # timeout --signal=SIGABRT 60m ./tst/webrtc_client_test + + # mbedtls-ubuntu-gcc-11: + # runs-on: ubuntu-latest + # env: + # AWS_KVS_LOG_LEVEL: 2 + # permissions: + # id-token: write + # contents: read + # steps: + # - name: Clone repository + # uses: actions/checkout@v3 + # - name: Configure AWS Credentials + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + # aws-region: ${{ secrets.AWS_REGION }} + # - name: Install deps + # run: | + # sudo apt clean && sudo apt update + # sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6' + # sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + # sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ jammy main' + # sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ jammy universe' + # sudo apt-get -q update + # - name: Build repository + # run: | + # mkdir build && cd build + # cmake .. -DBUILD_TEST=TRUE -DUSE_OPENSSL=OFF -DUSE_MBEDTLS=ON + # make + # ulimit -c unlimited -S + # - name: Run tests + # run: | + # cd build + # timeout --signal=SIGABRT 60m ./tst/webrtc_client_test + # mbedtls-ubuntu-clang: + # runs-on: ubuntu-20.04 + # env: + # CC: clang + # CXX: clang++ + # AWS_KVS_LOG_LEVEL: 2 + # permissions: + # id-token: write + # contents: read + # steps: + # - name: Clone repository + # uses: actions/checkout@v3 + # - name: Configure AWS Credentials + # uses: aws-actions/configure-aws-credentials@v2 + # with: + # role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + # aws-region: ${{ secrets.AWS_REGION }} + # - name: Install dependencies + # run: | # sudo apt clean && sudo apt update - # sudo apt-get -y install clang-7 + # sudo apt-get -y install clang # - name: Build repository # run: | # sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6' # mkdir build && cd build - # cmake .. -DMEMORY_SANITIZER=TRUE -DBUILD_TEST=TRUE + # cmake .. -DBUILD_TEST=TRUE -DUSE_OPENSSL=OFF -DUSE_MBEDTLS=ON # make # ulimit -c unlimited -S # timeout --signal=SIGABRT 60m build/tst/webrtc_client_test @@ -612,17 +949,18 @@ jobs: # windows-msvc-mbedtls: # runs-on: windows-2022 # env: - # AWS_KVS_LOG_LEVEL: 7 + # AWS_KVS_LOG_LEVEL: 2 + # permissions: + # id-token: write + # contents: read # steps: # - name: Clone repository # uses: actions/checkout@v4 # - name: Move cloned repo # shell: powershell # run: | - # mkdir D:\a\webrtc - # Move-Item -Path "D:\a\amazon-kinesis-video-streams-webrtc-sdk-c\amazon-kinesis-video-streams-webrtc-sdk-c\*" -Destination "D:\a\webrtc" - # cd D:\a\webrtc - # dir + # mkdir C:\webrtc + # Move-Item -Path "D:\a\amazon-kinesis-video-streams-webrtc-sdk-c\amazon-kinesis-video-streams-webrtc-sdk-c\*" -Destination "C:\webrtc" # - name: Install dependencies # shell: powershell # run: | @@ -631,10 +969,23 @@ jobs: # curl.exe -o C:\tools\pthreads-w32-2-9-1-release.zip ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip # mkdir C:\tools\pthreads-w32-2-9-1-release\ # Expand-Archive -Path C:\tools\pthreads-w32-2-9-1-release.zip -DestinationPath C:\tools\pthreads-w32-2-9-1-release + # # - name: Build libwebsockets from source + # # shell: powershell + # # run: | + # # $env:Path += ';C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Strawberry\c\bin;C:\Program Files\NASM;D:\a\amazon-kinesis-video-streams-webrtc-sdk-c\amazon-kinesis-video-streams-webrtc-sdk-c\open-source\bin;C:\tools\pthreads-w32-2-9-1-release\Pre-built.2\lib\x64;C:\tools\pthreads-w32-2-9-1-release\Pre-built.2\include' + # # git config --system core.longpaths true + # # cd C:\tools\ + # # git clone https://github.com/warmcat/libwebsockets.git + # # git checkout v4.2.2 + # # cd libwebsockets + # # mkdir build + # # cd build + # # cmake .. -DLWS_HAVE_PTHREAD_H=1 -DLWS_EXT_PTHREAD_INCLUDE_DIR="C:\\tools\\pthreads-w32-2-9-1-release\\Pre-built.2\\include" -DLWS_EXT_PTHREAD_LIBRARIES="C:\\tools\\pthreads-w32-2-9-1-release\\Pre-built.2\\lib\\x64\\libpthreadGC2.a" -DLWS_WITH_MINIMAL_EXAMPLES=1 -DLWS_OPENSSL_INCLUDE_DIRS="C:\\Program Files\\OpenSSL\\include" -DLWS_OPENSSL_LIBRARIES="C:\\Program Files\\OpenSSL\\lib\\libssl.lib;C:\\Program Files\\OpenSSL\\lib\\libcrypto.lib" + # # cmake --build . --config DEBUG # - name: Build repository # shell: powershell # run: | - # cd D:\a\webrtc + # cd C:\webrtc # git config --system core.longpaths true # .github\build_windows_mbedtls.bat arm64-cross-compilation: From 95da6ad1e835c8395b1d29813906ce424b3ca90d Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Wed, 6 Dec 2023 15:34:17 -0800 Subject: [PATCH 11/31] Remove unused retStatus declaration --- src/source/Ice/NatBehaviorDiscovery.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/source/Ice/NatBehaviorDiscovery.c b/src/source/Ice/NatBehaviorDiscovery.c index a0b70e4721..8ccc1d0666 100644 --- a/src/source/Ice/NatBehaviorDiscovery.c +++ b/src/source/Ice/NatBehaviorDiscovery.c @@ -9,7 +9,6 @@ STATUS natTestIncomingDataHandler(UINT64 customData, PSocketConnection pSocketCo UNUSED_PARAM(pSrc); UNUSED_PARAM(pDest); - STATUS retStatus = STATUS_SUCCESS; PNatTestData pNatTestData = (PNatTestData) customData; PStunPacket pStunPacket = NULL; From d2e28539ae875d3de74bb0ab1186cf1d45b9d9a0 Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Wed, 6 Dec 2023 15:54:29 -0800 Subject: [PATCH 12/31] Reverted removing retstatus, changed to return successful retstatus --- src/source/Ice/NatBehaviorDiscovery.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/source/Ice/NatBehaviorDiscovery.c b/src/source/Ice/NatBehaviorDiscovery.c index 8ccc1d0666..a0b70e4721 100644 --- a/src/source/Ice/NatBehaviorDiscovery.c +++ b/src/source/Ice/NatBehaviorDiscovery.c @@ -9,6 +9,7 @@ STATUS natTestIncomingDataHandler(UINT64 customData, PSocketConnection pSocketCo UNUSED_PARAM(pSrc); UNUSED_PARAM(pDest); + STATUS retStatus = STATUS_SUCCESS; PNatTestData pNatTestData = (PNatTestData) customData; PStunPacket pStunPacket = NULL; From 9c3a3f664ba2af12a2cdc226902b9da80051a6c3 Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Wed, 6 Dec 2023 16:47:19 -0800 Subject: [PATCH 13/31] Add default case for NatBehaviorStr --- src/source/Ice/NatBehaviorDiscovery.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/source/Ice/NatBehaviorDiscovery.c b/src/source/Ice/NatBehaviorDiscovery.c index a0b70e4721..9110e2aa1e 100644 --- a/src/source/Ice/NatBehaviorDiscovery.c +++ b/src/source/Ice/NatBehaviorDiscovery.c @@ -380,5 +380,8 @@ PCHAR getNatBehaviorStr(NAT_BEHAVIOR natBehavior) return NAT_BEHAVIOR_ADDRESS_DEPENDENT_STR; case NAT_BEHAVIOR_PORT_DEPENDENT: return NAT_BEHAVIOR_PORT_DEPENDENT_STR; + default: + // NOTE: This should be properly handled with something like "NAT_BEHAVIOR_UNDEFINED" + return NAT_BEHAVIOR_NONE_STR; } } From caa436d303c2250d5f4aa1eb4ddfff149013c3fb Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:15:54 -0800 Subject: [PATCH 14/31] Switch to signed int for >=0 evaluation --- src/source/Ice/Network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/source/Ice/Network.c b/src/source/Ice/Network.c index b5568bb97b..504a3030c7 100644 --- a/src/source/Ice/Network.c +++ b/src/source/Ice/Network.c @@ -338,7 +338,7 @@ STATUS socketWrite(INT32 sockfd, const void* pBuffer, SIZE_T length) BOOL isIpAddr(PCHAR hostname, UINT16 length) { BOOL status = TRUE; - UINT32 ip_1, ip_2, ip_3, ip_4, ip_5, ip_6, ip_7, ip_8; + INT16 ip_1, ip_2, ip_3, ip_4, ip_5, ip_6, ip_7, ip_8; if (hostname == NULL || length > MAX_ICE_CONFIG_URI_LEN) { DLOGW("Provided NULL hostname"); status = FALSE; From d2fb602fff2d6f3aeb510a032ca9fdd7211b409e Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:32:00 -0800 Subject: [PATCH 15/31] Switch to INT32 --- src/source/Ice/Network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/source/Ice/Network.c b/src/source/Ice/Network.c index 504a3030c7..777b10666b 100644 --- a/src/source/Ice/Network.c +++ b/src/source/Ice/Network.c @@ -338,7 +338,7 @@ STATUS socketWrite(INT32 sockfd, const void* pBuffer, SIZE_T length) BOOL isIpAddr(PCHAR hostname, UINT16 length) { BOOL status = TRUE; - INT16 ip_1, ip_2, ip_3, ip_4, ip_5, ip_6, ip_7, ip_8; + INT32 ip_1, ip_2, ip_3, ip_4, ip_5, ip_6, ip_7, ip_8; if (hostname == NULL || length > MAX_ICE_CONFIG_URI_LEN) { DLOGW("Provided NULL hostname"); status = FALSE; From 018df56d40ee1966e73faf72cc5175258efdf191 Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:47:43 -0800 Subject: [PATCH 16/31] Remove unused variable "sendStatus" --- src/source/Ice/TurnConnection.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/source/Ice/TurnConnection.c b/src/source/Ice/TurnConnection.c index 7761b757a9..648524de14 100644 --- a/src/source/Ice/TurnConnection.c +++ b/src/source/Ice/TurnConnection.c @@ -1027,7 +1027,7 @@ BOOL turnConnectionGetRelayAddress(PTurnConnection pTurnConnection, PKvsIpAddres STATUS checkTurnPeerConnections(PTurnConnection pTurnConnection) { - STATUS retStatus = STATUS_SUCCESS, sendStatus = STATUS_SUCCESS; + STATUS retStatus = STATUS_SUCCESS; PTurnPeer pTurnPeer = NULL; PStunAttributeAddress pStunAttributeAddress = NULL; PStunAttributeChannelNumber pStunAttributeChannelNumber = NULL; @@ -1054,7 +1054,7 @@ STATUS checkTurnPeerConnections(PTurnConnection pTurnConnection) CHK(pTurnPeer->pTransactionIdStore != NULL, STATUS_INVALID_OPERATION); transactionIdStoreInsert(pTurnPeer->pTransactionIdStore, pTurnConnection->pTurnCreatePermissionPacket->header.transactionId); - sendStatus = iceUtilsSendStunPacket(pTurnConnection->pTurnCreatePermissionPacket, pTurnConnection->longTermKey, + iceUtilsSendStunPacket(pTurnConnection->pTurnCreatePermissionPacket, pTurnConnection->longTermKey, ARRAY_SIZE(pTurnConnection->longTermKey), &pTurnConnection->turnServer.ipAddress, pTurnConnection->pControlChannel, NULL, FALSE); @@ -1080,7 +1080,7 @@ STATUS checkTurnPeerConnections(PTurnConnection pTurnConnection) CHK(pTurnPeer->pTransactionIdStore != NULL, STATUS_INVALID_OPERATION); transactionIdStoreInsert(pTurnPeer->pTransactionIdStore, pTurnConnection->pTurnChannelBindPacket->header.transactionId); - sendStatus = iceUtilsSendStunPacket(pTurnConnection->pTurnChannelBindPacket, pTurnConnection->longTermKey, + iceUtilsSendStunPacket(pTurnConnection->pTurnChannelBindPacket, pTurnConnection->longTermKey, ARRAY_SIZE(pTurnConnection->longTermKey), &pTurnConnection->turnServer.ipAddress, pTurnConnection->pControlChannel, NULL, FALSE); } From d37d1fa1fb7df6e1e7f4e63569e0ce90842aa57a Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Wed, 6 Dec 2023 19:25:00 -0800 Subject: [PATCH 17/31] Cast variables to void to avoid "set but not used" errors --- src/source/PeerConnection/Rtcp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/source/PeerConnection/Rtcp.c b/src/source/PeerConnection/Rtcp.c index d54fec9091..9c3ec7ea74 100644 --- a/src/source/PeerConnection/Rtcp.c +++ b/src/source/PeerConnection/Rtcp.c @@ -132,6 +132,12 @@ static STATUS onRtcpReceiverReport(PRtcpPacket pRtcpPacket, PKvsPeerConnection p pTransceiver->remoteInboundStats.roundTripTime = rttPropDelayMsec; MUTEX_UNLOCK(pTransceiver->statsLock); + // Cast to void to avoid "set but not used" warning + (void)senderSSRC; + (void)cumulativeLost; + (void)extHiSeqNumReceived; + (void)interarrivalJitter; + CleanUp: return retStatus; From aa993ca588916b6399fa37df8d2d11b60ea6390b Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Wed, 6 Dec 2023 20:23:46 -0800 Subject: [PATCH 18/31] Change SPRINTF to SNPRINTF --- src/source/PeerConnection/SessionDescription.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/source/PeerConnection/SessionDescription.c b/src/source/PeerConnection/SessionDescription.c index b07b4cd501..56aae117b3 100644 --- a/src/source/PeerConnection/SessionDescription.c +++ b/src/source/PeerConnection/SessionDescription.c @@ -450,6 +450,7 @@ STATUS populateSingleMediaSection(PKvsPeerConnection pKvsPeerConnection, PKvsRtp CHK_STATUS(iceAgentPopulateSdpMediaDescriptionCandidates(pKvsPeerConnection->pIceAgent, pSdpMediaDescription, MAX_SDP_ATTRIBUTE_VALUE_LENGTH, &attributeCount)); + // TODO: Verify full string fit into buffer for each of the SNPRINTFs below. if (containRtx) { STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeName, "msid"); amountWritten = SNPRINTF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue, From d8c3b35832cff47d5f5592347feb78b0c55db830 Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:00:43 -0800 Subject: [PATCH 19/31] Add buffer length to SessionDescription.c --- src/source/PeerConnection/SessionDescription.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/source/PeerConnection/SessionDescription.c b/src/source/PeerConnection/SessionDescription.c index 56aae117b3..9172e4573a 100644 --- a/src/source/PeerConnection/SessionDescription.c +++ b/src/source/PeerConnection/SessionDescription.c @@ -403,7 +403,7 @@ STATUS populateSingleMediaSection(PKvsPeerConnection pKvsPeerConnection, PKvsRtp UINT64 payloadType, rtxPayloadType; BOOL containRtx = FALSE; BOOL directionFound = FALSE; - UINT32 i, remoteAttributeCount, attributeCount = 0; + UINT32 i, remoteAttributeCount, attributeCount, attributeNameBuffLen, amountWritten = 0; PRtcMediaStreamTrack pRtcMediaStreamTrack = &(pKvsRtpTransceiver->sender.track); PSdpMediaDescription pSdpMediaDescriptionRemote; PCHAR currentFmtp = NULL, rtpMapValue = NULL; @@ -450,7 +450,7 @@ STATUS populateSingleMediaSection(PKvsPeerConnection pKvsPeerConnection, PKvsRtp CHK_STATUS(iceAgentPopulateSdpMediaDescriptionCandidates(pKvsPeerConnection->pIceAgent, pSdpMediaDescription, MAX_SDP_ATTRIBUTE_VALUE_LENGTH, &attributeCount)); - // TODO: Verify full string fit into buffer for each of the SNPRINTFs below. + attributeNameBuffLen = SIZEOF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeName); if (containRtx) { STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeName, "msid"); amountWritten = SNPRINTF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue, @@ -806,12 +806,6 @@ STATUS populateSessionDescriptionDataChannel(PKvsPeerConnection pKvsPeerConnecti STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue, pKvsPeerConnection->localIcePwd); attributeCount++; - if (pKvsPeerConnection->canTrickleIce.value) { - STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeName, "ice-options"); - STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue, "trickle"); - attributeCount++; - } - STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeName, "fingerprint"); STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue, "sha-256 "); STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue + 8, pCertificateFingerprint); From bd680a38c2a8ddeee9400cab7810b1c658e79f1b Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:02:18 -0800 Subject: [PATCH 20/31] Add back accidentally removed code block --- src/source/PeerConnection/SessionDescription.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/source/PeerConnection/SessionDescription.c b/src/source/PeerConnection/SessionDescription.c index 9172e4573a..3008bdfbf2 100644 --- a/src/source/PeerConnection/SessionDescription.c +++ b/src/source/PeerConnection/SessionDescription.c @@ -806,6 +806,12 @@ STATUS populateSessionDescriptionDataChannel(PKvsPeerConnection pKvsPeerConnecti STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue, pKvsPeerConnection->localIcePwd); attributeCount++; + if (pKvsPeerConnection->canTrickleIce.value) { + STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeName, "ice-options"); + STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue, "trickle"); + attributeCount++; + } + STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeName, "fingerprint"); STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue, "sha-256 "); STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue + 8, pCertificateFingerprint); From 547e1eae32754ba5d8cb0fc67782dd6eb0488867 Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski Date: Thu, 7 Dec 2023 21:10:38 +0000 Subject: [PATCH 21/31] Comment out most of cmakelists to speedup testing --- CMakeLists.txt | 133 ++++++++++++++++++++++++++++--------------------- 1 file changed, 77 insertions(+), 56 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97decb4acf..4cebee43ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,16 +108,16 @@ if(ADD_MUCLIBC) endif() -message(STATUS "Kinesis Video WebRTC Client path is ${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}") -message(STATUS "dependencies install path is ${OPEN_SRC_INSTALL_PREFIX}") +# message(STATUS "Kinesis Video WebRTC Client path is ${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}") +# message(STATUS "dependencies install path is ${OPEN_SRC_INSTALL_PREFIX}") -# pass ca cert location to sdk -add_definitions(-DKVS_CA_CERT_PATH="${CMAKE_SOURCE_DIR}/certs/cert.pem") -add_definitions(-DCMAKE_DETECTED_CACERT_PATH) +# # pass ca cert location to sdk +# add_definitions(-DKVS_CA_CERT_PATH="${CMAKE_SOURCE_DIR}/certs/cert.pem") +# add_definitions(-DCMAKE_DETECTED_CACERT_PATH) -if (ENABLE_KVS_THREADPOOL) - add_definitions(-DENABLE_KVS_THREADPOOL) -endif() +# if (ENABLE_KVS_THREADPOOL) +# add_definitions(-DENABLE_KVS_THREADPOOL) +# endif() if(USE_OPENSSL) add_definitions(-DKVS_USE_OPENSSL) @@ -142,10 +142,31 @@ elseif(USE_MBEDTLS) endif() -if(BUILD_DEPENDENCIES) - if(NOT EXISTS ${OPEN_SRC_INSTALL_PREFIX}) - file(MAKE_DIRECTORY ${OPEN_SRC_INSTALL_PREFIX}) - endif() +# if(WIN32) +# set(OPENSSL_INCLUDE_DIRS "${OPEN_SRC_INSTALL_PREFIX}/include/") +# set(OPENSSL_CRYPTO_LIBRARY "${OPEN_SRC_INSTALL_PREFIX}/lib/libcrypto.lib") +# set(OPENSSL_SSL_LIBRARY "${OPEN_SRC_INSTALL_PREFIX}/lib/libssl.lib") +# set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}) +# string(REPLACE ";" "|" OPENSSL_LIBRARIES_ALT_SEP "${OPENSSL_LIBRARIES}") +# set(BUILD_ARGS -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS} +# -DUSE_OPENSSL=${USE_OPENSSL} +# -DUSE_MBEDTLS=${USE_MBEDTLS} +# -DLWS_EXT_PTHREAD_INCLUDE_DIR=${EXT_PTHREAD_INCLUDE_DIR} +# -DLWS_EXT_PTHREAD_LIBRARIES=${EXT_PTHREAD_LIBRARIES} +# -DLWS_OPENSSL_INCLUDE_DIRS=${OPENSSL_INCLUDE_DIRS} +# -DLWS_OPENSSL_LIBRARIES=${OPENSSL_LIBRARIES_ALT_SEP} +# -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}) +# else() +# set(BUILD_ARGS -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS} +# -DOPENSSL_DIR=${OPEN_SRC_INSTALL_PREFIX} +# -DUSE_OPENSSL=${USE_OPENSSL} +# -DUSE_MBEDTLS=${USE_MBEDTLS} +# -DLWS_OPENSSL_CRYPTO_LIBRARY=${OPENSSL_CRYPTO_LIBRARY} +# -DLWS_OPENSSL_SSL_LIBRARY=${OPENSSL_SSL_LIBRARY} +# -DLWS_OPENSSL_INCLUDE_DIRS=${OPENSSL_INCLUDE_DIR} +# -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}) +# endif() +# build_dependency(websockets ${BUILD_ARGS}) set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${OPEN_SRC_INSTALL_PREFIX}/lib/pkgconfig") set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${OPEN_SRC_INSTALL_PREFIX}) @@ -238,15 +259,15 @@ if(BUILD_DEPENDENCIES) endif() - if(BUILD_BENCHMARK) - build_dependency(benchmark) - endif() +# if(BUILD_BENCHMARK) +# build_dependency(benchmark) +# endif() - if (LINK_PROFILER) - build_dependency(gperftools) - endif() - message(STATUS "Finished building dependencies.") -endif() +# if (LINK_PROFILER) +# build_dependency(gperftools) +# endif() +# message(STATUS "Finished building dependencies.") +# endif() # building kvsCommonLws also builds kvspic set(BUILD_ARGS @@ -259,45 +280,45 @@ build_dependency(kvsCommonLws ${BUILD_ARGS}) ############# find dependent libraries ############ -find_package(Threads) -find_package(PkgConfig REQUIRED) -if (USE_OPENSSL) - find_package(OpenSSL REQUIRED) - set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) -else() - find_package(MbedTLS REQUIRED) - set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${MBEDTLS_INCLUDE_DIRS}) -endif() - -if (OPEN_SRC_INSTALL_PREFIX) - find_library(SRTP_LIBRARIES srtp2 REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX}) - - if (LINK_PROFILER) - find_library(GPERFTOOLS_MALLOC_LIBRARIES tcmalloc REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX}) - find_library(GPERFTOOLS_PROFILER_LIBRARIES profiler REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX}) - endif() -else() - find_library(SRTP_LIBRARIES srtp2 REQUIRED ) - if (LINK_PROFILER) - find_library(GPERFTOOLS_MALLOC_LIBRARIES tcmalloc REQUIRED) - find_library(GPERFTOOLS_PROFILER_LIBRARIES profiler REQUIRED) - endif() -endif() - -if (WIN32) - SET(LIBWEBSOCKETS_LIBRARIES "websockets.lib") -else() - pkg_check_modules(LIBWEBSOCKETS REQUIRED libwebsockets) -endif() +# find_package(Threads) +# find_package(PkgConfig REQUIRED) +# if (USE_OPENSSL) +# find_package(OpenSSL REQUIRED) +# set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) +# else() +# find_package(MbedTLS REQUIRED) +# set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${MBEDTLS_INCLUDE_DIRS}) +# endif() + +# if (OPEN_SRC_INSTALL_PREFIX) +# find_library(SRTP_LIBRARIES srtp2 REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX}) + +# if (LINK_PROFILER) +# find_library(GPERFTOOLS_MALLOC_LIBRARIES tcmalloc REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX}) +# find_library(GPERFTOOLS_PROFILER_LIBRARIES profiler REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX}) +# endif() +# else() +# find_library(SRTP_LIBRARIES srtp2 REQUIRED ) +# if (LINK_PROFILER) +# find_library(GPERFTOOLS_MALLOC_LIBRARIES tcmalloc REQUIRED) +# find_library(GPERFTOOLS_PROFILER_LIBRARIES profiler REQUIRED) +# endif() +# endif() + +# if (WIN32) +# SET(LIBWEBSOCKETS_LIBRARIES "websockets.lib") +# else() +# pkg_check_modules(LIBWEBSOCKETS REQUIRED libwebsockets) +# endif() # usrsctp dont support pkgconfig yet -find_library( - Usrsctp - NAMES ${USRSCTP_LIBNAME} usrsctp REQUIRED - PATHS ${OPEN_SRC_INSTALL_PREFIX}/lib ${OPEN_SRC_INSTALL_PREFIX}/lib64) +# find_library( +# Usrsctp +# NAMES ${USRSCTP_LIBNAME} usrsctp REQUIRED +# PATHS ${OPEN_SRC_INSTALL_PREFIX}/lib ${OPEN_SRC_INSTALL_PREFIX}/lib64) -set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${LIBSRTP_INCLUDE_DIRS} - ${CURL_INCLUDE_DIRS} ${LIBWEBSOCKETS_INCLUDE_DIRS}) +# set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${LIBSRTP_INCLUDE_DIRS} +# ${CURL_INCLUDE_DIRS} ${LIBWEBSOCKETS_INCLUDE_DIRS}) link_directories(${LIBSRTP_LIBRARY_DIRS}) link_directories(${LIBWEBSOCKETS_LIBRARY_DIRS}) From d5d3b15182ff853905bdc13ae44f05468688f3ce Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:14:50 -0800 Subject: [PATCH 22/31] Revert "Comment out most of cmakelists to speedup testing" This reverts commit 8af00c8b6e463e98e5ad6a268cbb6640e0db15b0. --- CMakeLists.txt | 157 +++++++++++++++++++++++++------------------------ 1 file changed, 79 insertions(+), 78 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cebee43ee..2f2c82b921 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,16 +108,16 @@ if(ADD_MUCLIBC) endif() -# message(STATUS "Kinesis Video WebRTC Client path is ${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}") -# message(STATUS "dependencies install path is ${OPEN_SRC_INSTALL_PREFIX}") +message(STATUS "Kinesis Video WebRTC Client path is ${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}") +message(STATUS "dependencies install path is ${OPEN_SRC_INSTALL_PREFIX}") -# # pass ca cert location to sdk -# add_definitions(-DKVS_CA_CERT_PATH="${CMAKE_SOURCE_DIR}/certs/cert.pem") -# add_definitions(-DCMAKE_DETECTED_CACERT_PATH) +# pass ca cert location to sdk +add_definitions(-DKVS_CA_CERT_PATH="${CMAKE_SOURCE_DIR}/certs/cert.pem") +add_definitions(-DCMAKE_DETECTED_CACERT_PATH) -# if (ENABLE_KVS_THREADPOOL) -# add_definitions(-DENABLE_KVS_THREADPOOL) -# endif() +if (ENABLE_KVS_THREADPOOL) + add_definitions(-DENABLE_KVS_THREADPOOL) +endif() if(USE_OPENSSL) add_definitions(-DKVS_USE_OPENSSL) @@ -132,6 +132,8 @@ elseif(USE_MBEDTLS) message(STATUS "Detected gcc") set(CMAKE_C_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"\" ${CMAKE_C_FLAGS}") set(CMAKE_CXX_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"\" ${CMAKE_CXX_FLAGS}") + # set(CMAKE_C_FLAGS "-Wno-error=stringop-overflow -I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"\" ${CMAKE_C_FLAGS}") + # set(CMAKE_CXX_FLAGS "-Wno-error=stringop-overflow -I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"\" ${CMAKE_CXX_FLAGS}") if(CMAKE_C_COMPILER_VERSION VERSION_GREATER "7.0") set(CMAKE_C_FLAGS "-Wno-error=stringop-overflow ${CMAKE_C_FLAGS}") set(CMAKE_CXX_FLAGS "-Wno-error=stringop-overflow ${CMAKE_CXX_FLAGS}") @@ -141,32 +143,31 @@ elseif(USE_MBEDTLS) endif() endif() - -# if(WIN32) -# set(OPENSSL_INCLUDE_DIRS "${OPEN_SRC_INSTALL_PREFIX}/include/") -# set(OPENSSL_CRYPTO_LIBRARY "${OPEN_SRC_INSTALL_PREFIX}/lib/libcrypto.lib") -# set(OPENSSL_SSL_LIBRARY "${OPEN_SRC_INSTALL_PREFIX}/lib/libssl.lib") -# set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}) -# string(REPLACE ";" "|" OPENSSL_LIBRARIES_ALT_SEP "${OPENSSL_LIBRARIES}") -# set(BUILD_ARGS -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS} -# -DUSE_OPENSSL=${USE_OPENSSL} -# -DUSE_MBEDTLS=${USE_MBEDTLS} -# -DLWS_EXT_PTHREAD_INCLUDE_DIR=${EXT_PTHREAD_INCLUDE_DIR} -# -DLWS_EXT_PTHREAD_LIBRARIES=${EXT_PTHREAD_LIBRARIES} -# -DLWS_OPENSSL_INCLUDE_DIRS=${OPENSSL_INCLUDE_DIRS} -# -DLWS_OPENSSL_LIBRARIES=${OPENSSL_LIBRARIES_ALT_SEP} -# -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}) -# else() -# set(BUILD_ARGS -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS} -# -DOPENSSL_DIR=${OPEN_SRC_INSTALL_PREFIX} -# -DUSE_OPENSSL=${USE_OPENSSL} -# -DUSE_MBEDTLS=${USE_MBEDTLS} -# -DLWS_OPENSSL_CRYPTO_LIBRARY=${OPENSSL_CRYPTO_LIBRARY} -# -DLWS_OPENSSL_SSL_LIBRARY=${OPENSSL_SSL_LIBRARY} -# -DLWS_OPENSSL_INCLUDE_DIRS=${OPENSSL_INCLUDE_DIR} -# -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}) -# endif() -# build_dependency(websockets ${BUILD_ARGS}) + if(WIN32) + set(OPENSSL_INCLUDE_DIRS "${OPEN_SRC_INSTALL_PREFIX}/include/") + set(OPENSSL_CRYPTO_LIBRARY "${OPEN_SRC_INSTALL_PREFIX}/lib/libcrypto.lib") + set(OPENSSL_SSL_LIBRARY "${OPEN_SRC_INSTALL_PREFIX}/lib/libssl.lib") + set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}) + string(REPLACE ";" "|" OPENSSL_LIBRARIES_ALT_SEP "${OPENSSL_LIBRARIES}") + set(BUILD_ARGS -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS} + -DUSE_OPENSSL=${USE_OPENSSL} + -DUSE_MBEDTLS=${USE_MBEDTLS} + -DLWS_EXT_PTHREAD_INCLUDE_DIR=${EXT_PTHREAD_INCLUDE_DIR} + -DLWS_EXT_PTHREAD_LIBRARIES=${EXT_PTHREAD_LIBRARIES} + -DLWS_OPENSSL_INCLUDE_DIRS=${OPENSSL_INCLUDE_DIRS} + -DLWS_OPENSSL_LIBRARIES=${OPENSSL_LIBRARIES_ALT_SEP} + -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}) + else() + set(BUILD_ARGS -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS} + -DOPENSSL_DIR=${OPEN_SRC_INSTALL_PREFIX} + -DUSE_OPENSSL=${USE_OPENSSL} + -DUSE_MBEDTLS=${USE_MBEDTLS} + -DLWS_OPENSSL_CRYPTO_LIBRARY=${OPENSSL_CRYPTO_LIBRARY} + -DLWS_OPENSSL_SSL_LIBRARY=${OPENSSL_SSL_LIBRARY} + -DLWS_OPENSSL_INCLUDE_DIRS=${OPENSSL_INCLUDE_DIR} + -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}) + endif() + build_dependency(websockets ${BUILD_ARGS}) set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${OPEN_SRC_INSTALL_PREFIX}/lib/pkgconfig") set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${OPEN_SRC_INSTALL_PREFIX}) @@ -259,15 +260,15 @@ endif() endif() -# if(BUILD_BENCHMARK) -# build_dependency(benchmark) -# endif() + if(BUILD_BENCHMARK) + build_dependency(benchmark) + endif() -# if (LINK_PROFILER) -# build_dependency(gperftools) -# endif() -# message(STATUS "Finished building dependencies.") -# endif() + if (LINK_PROFILER) + build_dependency(gperftools) + endif() + message(STATUS "Finished building dependencies.") +endif() # building kvsCommonLws also builds kvspic set(BUILD_ARGS @@ -280,45 +281,45 @@ build_dependency(kvsCommonLws ${BUILD_ARGS}) ############# find dependent libraries ############ -# find_package(Threads) -# find_package(PkgConfig REQUIRED) -# if (USE_OPENSSL) -# find_package(OpenSSL REQUIRED) -# set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) -# else() -# find_package(MbedTLS REQUIRED) -# set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${MBEDTLS_INCLUDE_DIRS}) -# endif() - -# if (OPEN_SRC_INSTALL_PREFIX) -# find_library(SRTP_LIBRARIES srtp2 REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX}) - -# if (LINK_PROFILER) -# find_library(GPERFTOOLS_MALLOC_LIBRARIES tcmalloc REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX}) -# find_library(GPERFTOOLS_PROFILER_LIBRARIES profiler REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX}) -# endif() -# else() -# find_library(SRTP_LIBRARIES srtp2 REQUIRED ) -# if (LINK_PROFILER) -# find_library(GPERFTOOLS_MALLOC_LIBRARIES tcmalloc REQUIRED) -# find_library(GPERFTOOLS_PROFILER_LIBRARIES profiler REQUIRED) -# endif() -# endif() - -# if (WIN32) -# SET(LIBWEBSOCKETS_LIBRARIES "websockets.lib") -# else() -# pkg_check_modules(LIBWEBSOCKETS REQUIRED libwebsockets) -# endif() +find_package(Threads) +find_package(PkgConfig REQUIRED) +if (USE_OPENSSL) + find_package(OpenSSL REQUIRED) + set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) +else() + find_package(MbedTLS REQUIRED) + set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${MBEDTLS_INCLUDE_DIRS}) +endif() + +if (OPEN_SRC_INSTALL_PREFIX) + find_library(SRTP_LIBRARIES srtp2 REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX}) + + if (LINK_PROFILER) + find_library(GPERFTOOLS_MALLOC_LIBRARIES tcmalloc REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX}) + find_library(GPERFTOOLS_PROFILER_LIBRARIES profiler REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX}) + endif() +else() + find_library(SRTP_LIBRARIES srtp2 REQUIRED ) + if (LINK_PROFILER) + find_library(GPERFTOOLS_MALLOC_LIBRARIES tcmalloc REQUIRED) + find_library(GPERFTOOLS_PROFILER_LIBRARIES profiler REQUIRED) + endif() +endif() + +if (WIN32) + SET(LIBWEBSOCKETS_LIBRARIES "websockets.lib") +else() + pkg_check_modules(LIBWEBSOCKETS REQUIRED libwebsockets) +endif() # usrsctp dont support pkgconfig yet -# find_library( -# Usrsctp -# NAMES ${USRSCTP_LIBNAME} usrsctp REQUIRED -# PATHS ${OPEN_SRC_INSTALL_PREFIX}/lib ${OPEN_SRC_INSTALL_PREFIX}/lib64) +find_library( + Usrsctp + NAMES ${USRSCTP_LIBNAME} usrsctp REQUIRED + PATHS ${OPEN_SRC_INSTALL_PREFIX}/lib ${OPEN_SRC_INSTALL_PREFIX}/lib64) -# set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${LIBSRTP_INCLUDE_DIRS} -# ${CURL_INCLUDE_DIRS} ${LIBWEBSOCKETS_INCLUDE_DIRS}) +set(OPEN_SRC_INCLUDE_DIRS ${OPEN_SRC_INCLUDE_DIRS} ${LIBSRTP_INCLUDE_DIRS} + ${CURL_INCLUDE_DIRS} ${LIBWEBSOCKETS_INCLUDE_DIRS}) link_directories(${LIBSRTP_LIBRARY_DIRS}) link_directories(${LIBWEBSOCKETS_LIBRARY_DIRS}) From eed8ba5b64d7dbb3e859e6429774d27b3e02b0e8 Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:37:21 -0800 Subject: [PATCH 23/31] Cast numeric macro to uint --- src/source/Rtcp/RtcpPacket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/source/Rtcp/RtcpPacket.c b/src/source/Rtcp/RtcpPacket.c index 9346f90af4..fe4d84cb07 100644 --- a/src/source/Rtcp/RtcpPacket.c +++ b/src/source/Rtcp/RtcpPacket.c @@ -15,7 +15,7 @@ STATUS setRtcpPacketFromBytes(PBYTE pRawPacket, UINT32 pRawPacketsLen, PRtcpPack // We don't assert exact length since this may be a compound packet, it // is the callers responsibility to parse subsequent entries packetLen = getInt16(*(PUINT16) (pRawPacket + RTCP_PACKET_LEN_OFFSET)); - CHK((packetLen + 1) * RTCP_PACKET_LEN_WORD_SIZE <= pRawPacketsLen, STATUS_RTCP_INPUT_PARTIAL_PACKET); + CHK((packetLen + 1) * ((UINT16) RTCP_PACKET_LEN_WORD_SIZE) <= pRawPacketsLen, STATUS_RTCP_INPUT_PARTIAL_PACKET); pRtcpPacket->header.version = (pRawPacket[0] >> VERSION_SHIFT) & VERSION_MASK; CHK(pRtcpPacket->header.version == RTCP_PACKET_VERSION_VAL, STATUS_RTCP_INPUT_PACKET_INVALID_VERSION); From 7bf70f44a970ff17cc376c17eee2939136df65fb Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Thu, 7 Dec 2023 14:07:18 -0800 Subject: [PATCH 24/31] Change what is casted in prev commit --- src/source/Rtcp/RtcpPacket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/source/Rtcp/RtcpPacket.c b/src/source/Rtcp/RtcpPacket.c index fe4d84cb07..dbcb1086ce 100644 --- a/src/source/Rtcp/RtcpPacket.c +++ b/src/source/Rtcp/RtcpPacket.c @@ -15,7 +15,7 @@ STATUS setRtcpPacketFromBytes(PBYTE pRawPacket, UINT32 pRawPacketsLen, PRtcpPack // We don't assert exact length since this may be a compound packet, it // is the callers responsibility to parse subsequent entries packetLen = getInt16(*(PUINT16) (pRawPacket + RTCP_PACKET_LEN_OFFSET)); - CHK((packetLen + 1) * ((UINT16) RTCP_PACKET_LEN_WORD_SIZE) <= pRawPacketsLen, STATUS_RTCP_INPUT_PARTIAL_PACKET); + CHK((UINT16)((packetLen + 1) * RTCP_PACKET_LEN_WORD_SIZE) <= pRawPacketsLen, STATUS_RTCP_INPUT_PARTIAL_PACKET); pRtcpPacket->header.version = (pRawPacket[0] >> VERSION_SHIFT) & VERSION_MASK; CHK(pRtcpPacket->header.version == RTCP_PACKET_VERSION_VAL, STATUS_RTCP_INPUT_PACKET_INVALID_VERSION); From 88eeb564580f69370d095e64b33f007a4ee45707 Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Thu, 7 Dec 2023 15:28:11 -0800 Subject: [PATCH 25/31] Cast to uint in Stun.c --- src/source/Stun/Stun.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/source/Stun/Stun.c b/src/source/Stun/Stun.c index a099e39a29..cc109ed632 100644 --- a/src/source/Stun/Stun.c +++ b/src/source/Stun/Stun.c @@ -555,7 +555,7 @@ STATUS deserializeStunPacket(PBYTE pStunBuffer, UINT32 bufferSize, PBYTE passwor magicCookie = (UINT32) getInt32(*(PUINT32) ((PBYTE) pStunHeader + STUN_HEADER_TYPE_LEN + STUN_HEADER_DATA_LEN)); // Validate the specified size - CHK(bufferSize >= messageLength + STUN_HEADER_LEN, STATUS_INVALID_ARG); + CHK(bufferSize >= (UINT16)(messageLength + STUN_HEADER_LEN), STATUS_INVALID_ARG); // Validate the magic cookie CHK(magicCookie == STUN_HEADER_MAGIC_COOKIE, STATUS_STUN_MAGIC_COOKIE_MISMATCH); From ed381da150fcbf1d759fee5bbc4fa15e11c71dba Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Thu, 7 Dec 2023 15:58:53 -0800 Subject: [PATCH 26/31] Fix comment "\", >=0 uint checks, cast to uint, remove retstatus /Users/runner/work/amazon-kinesis-video-streams-webrtc-sdk-c/amazon-kinesis-video-streams-webrtc-sdk-c/src/source/Sctp/Sctp.c:213:1: error: multi-line comment [-Werror=comment] 213 | // / \ | ^ /Users/runner/work/amazon-kinesis-video-streams-webrtc-sdk-c/amazon-kinesis-video-streams-webrtc-sdk-c/src/source/Sctp/Sctp.c:217:1: error: multi-line comment [-Werror=comment] 217 | // / \ | ^ /Users/runner/work/amazon-kinesis-video-streams-webrtc-sdk-c/amazon-kinesis-video-streams-webrtc-sdk-c/src/source/Sctp/Sctp.c: In function 'sctpSessionWriteDcep': /Users/runner/work/amazon-kinesis-video-streams-webrtc-sdk-c/amazon-kinesis-video-streams-webrtc-sdk-c/src/source/Sctp/Sctp.c:249:51: error: comparison is always true due to limited range of data type [-Werror=type-limits] 249 | if (pRtcDataChannelInit->maxRetransmits.value >= 0 && pRtcDataChannelInit->maxRetransmits.isNull == FALSE) { | ^~ /Users/runner/work/amazon-kinesis-video-streams-webrtc-sdk-c/amazon-kinesis-video-streams-webrtc-sdk-c/src/source/Sctp/Sctp.c:252:61: error: comparison is always true due to limited range of data type [-Werror=type-limits] 252 | } else if (pRtcDataChannelInit->maxPacketLifeTime.value >= 0 && pRtcDataChannelInit->maxPacketLifeTime.isNull == FALSE) { | ^~ In file included from /Users/runner/work/amazon-kinesis-video-streams-webrtc-sdk-c/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/include/com/amazonaws/kinesis/video/client/Include.h:13, from /Users/runner/work/amazon-kinesis-video-streams-webrtc-sdk-c/amazon-kinesis-video-streams-webrtc-sdk-c/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h:20, from /Users/runner/work/amazon-kinesis-video-streams-webrtc-sdk-c/amazon-kinesis-video-streams-webrtc-sdk-c/src/source/Sctp/../Include_i.h:27, from /Users/runner/work/amazon-kinesis-video-streams-webrtc-sdk-c/amazon-kinesis-video-streams-webrtc-sdk-c/src/source/Sctp/Sctp.c:2: /Users/runner/work/amazon-kinesis-video-streams-webrtc-sdk-c/amazon-kinesis-video-streams-webrtc-sdk-c/src/source/Sctp/Sctp.c: In function 'handleDcepPacket': /Users/runner/work/amazon-kinesis-video-streams-webrtc-sdk-c/amazon-kinesis-video-streams-webrtc-sdk-c/src/source/Sctp/Sctp.c:318:66: error: comparison of integer expressions of different signedness: 'int' and 'SIZE_T' {aka 'long long unsigned int'} [-Werror=sign-compare] 318 | CHK((labelLength + protocolLength + SCTP_DCEP_HEADER_LENGTH) >= length, STATUS_SCTP_INVALID_DCEP_PACKET); | ^~ /Users/runner/work/amazon-kinesis-video-streams-webrtc-sdk-c/amazon-kinesis-video-streams-webrtc-sdk-c/src/source/Sctp/Sctp.c: In function 'onSctpInboundPacket': /Users/runner/work/amazon-kinesis-video-streams-webrtc-sdk-c/amazon-kinesis-video-streams-webrtc-sdk-c/src/source/Sctp/Sctp.c:336:12: error: variable 'retStatus' set but not used [-Werror=unused-but-set-variable] 336 | STATUS retStatus = STATUS_SUCCESS; | ^~~~~~~~~ At top level: cc1: note: unrecognized command-line option '-Wno-unknown-warning-option' may have been intended to silence earlier diagnostics cc1: all warnings being treated as errors make[2]: *** [CMakeFiles/kvsWebrtcClient.dir/src/source/Sctp/Sctp.c.o] Error 1 make[1]: *** [CMakeFiles/kvsWebrtcClient.dir/all] Error 2 make: *** [all] Error 2 Error: Process completed with exit code 2. --- src/source/Sctp/Sctp.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/source/Sctp/Sctp.c b/src/source/Sctp/Sctp.c index 2af922e0cd..2c5473effb 100644 --- a/src/source/Sctp/Sctp.c +++ b/src/source/Sctp/Sctp.c @@ -208,13 +208,13 @@ STATUS sctpSessionWriteMessage(PSctpSession pSctpSession, UINT32 streamId, BOOL // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // | Label Length | Protocol Length | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// \ / +// | | // | Label | -// / \ +// | | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// \ / +// | | // | Protocol | -// / \ +// | | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ STATUS sctpSessionWriteDcep(PSctpSession pSctpSession, UINT32 streamId, PCHAR pChannelName, UINT32 pChannelNameLen, PRtcDataChannelInit pRtcDataChannelInit) @@ -246,10 +246,10 @@ STATUS sctpSessionWriteDcep(PSctpSession pSctpSession, UINT32 streamId, PCHAR pC if (!pRtcDataChannelInit->ordered) { pSctpSession->packet[1] |= DCEP_DATA_CHANNEL_RELIABLE_UNORDERED; } - if (pRtcDataChannelInit->maxRetransmits.value >= 0 && pRtcDataChannelInit->maxRetransmits.isNull == FALSE) { + if (pRtcDataChannelInit->maxRetransmits.isNull == FALSE) { pSctpSession->packet[1] |= DCEP_DATA_CHANNEL_REXMIT; putUnalignedInt32BigEndian(pSctpSession->packet + SIZEOF(UINT32), pRtcDataChannelInit->maxRetransmits.value); - } else if (pRtcDataChannelInit->maxPacketLifeTime.value >= 0 && pRtcDataChannelInit->maxPacketLifeTime.isNull == FALSE) { + } else if (pRtcDataChannelInit->maxPacketLifeTime.isNull == FALSE) { pSctpSession->packet[1] |= DCEP_DATA_CHANNEL_TIMED; putUnalignedInt32BigEndian(pSctpSession->packet + SIZEOF(UINT32), pRtcDataChannelInit->maxPacketLifeTime.value); } @@ -315,7 +315,7 @@ STATUS handleDcepPacket(PSctpSession pSctpSession, UINT32 streamId, PBYTE data, putInt16((PINT16) &labelLength, labelLength); putInt16((PINT16) &protocolLength, protocolLength); - CHK((labelLength + protocolLength + SCTP_DCEP_HEADER_LENGTH) >= length, STATUS_SCTP_INVALID_DCEP_PACKET); + CHK((UINT16) (labelLength + protocolLength + SCTP_DCEP_HEADER_LENGTH) >= length, STATUS_SCTP_INVALID_DCEP_PACKET); CHK(SCTP_MAX_ALLOWABLE_PACKET_LENGTH >= length, STATUS_SCTP_INVALID_DCEP_PACKET); @@ -333,7 +333,6 @@ INT32 onSctpInboundPacket(struct socket* sock, union sctp_sockstore addr, PVOID UNUSED_PARAM(sock); UNUSED_PARAM(addr); UNUSED_PARAM(flags); - STATUS retStatus = STATUS_SUCCESS; PSctpSession pSctpSession = (PSctpSession) ulp_info; BOOL isBinary = FALSE; From 61dc9cd6acdb4d7b523674b4f22e3b9db9962842 Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Thu, 7 Dec 2023 16:14:27 -0800 Subject: [PATCH 27/31] Add back retStatus --- src/source/Sctp/Sctp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/source/Sctp/Sctp.c b/src/source/Sctp/Sctp.c index 2c5473effb..4b5414bc38 100644 --- a/src/source/Sctp/Sctp.c +++ b/src/source/Sctp/Sctp.c @@ -333,6 +333,7 @@ INT32 onSctpInboundPacket(struct socket* sock, union sctp_sockstore addr, PVOID UNUSED_PARAM(sock); UNUSED_PARAM(addr); UNUSED_PARAM(flags); + STATUS retStatus = STATUS_SUCCESS; PSctpSession pSctpSession = (PSctpSession) ulp_info; BOOL isBinary = FALSE; From ebfb11f222eac8279891c4cb7d8446c69d14da8d Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Thu, 7 Dec 2023 16:15:37 -0800 Subject: [PATCH 28/31] Change from (void) to UNUSED_PARAM() --- src/source/PeerConnection/Rtcp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/source/PeerConnection/Rtcp.c b/src/source/PeerConnection/Rtcp.c index 9c3ec7ea74..0b672cd80a 100644 --- a/src/source/PeerConnection/Rtcp.c +++ b/src/source/PeerConnection/Rtcp.c @@ -133,10 +133,10 @@ static STATUS onRtcpReceiverReport(PRtcpPacket pRtcpPacket, PKvsPeerConnection p MUTEX_UNLOCK(pTransceiver->statsLock); // Cast to void to avoid "set but not used" warning - (void)senderSSRC; - (void)cumulativeLost; - (void)extHiSeqNumReceived; - (void)interarrivalJitter; + UNUSED_PARAM(senderSSRC); + UNUSED_PARAM(cumulativeLost); + UNUSED_PARAM(extHiSeqNumReceived); + UNUSED_PARAM(interarrivalJitter); CleanUp: From b315e66401ec2b1b5156730c57425d6a1adf11ea Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Thu, 7 Dec 2023 17:44:21 -0800 Subject: [PATCH 29/31] Cast resStatus to void in cleanup --- src/source/Sctp/Sctp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/source/Sctp/Sctp.c b/src/source/Sctp/Sctp.c index 4b5414bc38..275837477b 100644 --- a/src/source/Sctp/Sctp.c +++ b/src/source/Sctp/Sctp.c @@ -358,6 +358,8 @@ INT32 onSctpInboundPacket(struct socket* sock, union sctp_sockstore addr, PVOID CleanUp: + UNUSED_PARAM(retStatus); + /* * IMPORTANT!!! The allocation is done in the sctp library using default allocator * so we need to use the default free API. From 1013018c197d6f80a5b340624038b7d3bd7d426e Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Fri, 8 Dec 2023 14:41:32 -0800 Subject: [PATCH 30/31] Update Tls_openssl.c --- src/source/Crypto/Tls_openssl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/source/Crypto/Tls_openssl.c b/src/source/Crypto/Tls_openssl.c index 0d2775a346..744d3595c2 100644 --- a/src/source/Crypto/Tls_openssl.c +++ b/src/source/Crypto/Tls_openssl.c @@ -214,7 +214,9 @@ STATUS tlsSessionPutApplicationData(PTlsSession pTlsSession, PBYTE pData, UINT32 } wBioGetMemDataRet = BIO_get_mem_data(SSL_get_wbio(pTlsSession->pSsl), &wBioBuffer); - CHK_ERR(wBioGetMemDataRet >= 0, STATUS_SEND_DATA_FAILED, "BIO_get_mem_data failed"); + CHK_ERR(wBioGetMemDataRet != 0, STATUS_SEND_DATA_FAILED, "BIO_get_mem_data failed with: no BIO was connected to the SSL object."); + CHK_ERR(wBioGetMemDataRet > 0, STATUS_SEND_DATA_FAILED, "BIO_get_mem_data failed"); + wBioDataLen = (SIZE_T) wBioGetMemDataRet; if (wBioDataLen > 0) { From 254f5a3ee95fc4680b347227506a9109f7581480 Mon Sep 17 00:00:00 2001 From: Stefan Kieszkowski <85728496+stefankiesz@users.noreply.github.com> Date: Thu, 21 Dec 2023 17:10:10 -0800 Subject: [PATCH 31/31] CLANG format --- src/source/Crypto/Tls_openssl.c | 2 +- src/source/Ice/TurnConnection.c | 9 ++++----- src/source/Rtcp/RtcpPacket.c | 2 +- src/source/Sctp/Sctp.c | 2 +- src/source/Stun/Stun.c | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/source/Crypto/Tls_openssl.c b/src/source/Crypto/Tls_openssl.c index 744d3595c2..c1bcc1899b 100644 --- a/src/source/Crypto/Tls_openssl.c +++ b/src/source/Crypto/Tls_openssl.c @@ -216,7 +216,7 @@ STATUS tlsSessionPutApplicationData(PTlsSession pTlsSession, PBYTE pData, UINT32 wBioGetMemDataRet = BIO_get_mem_data(SSL_get_wbio(pTlsSession->pSsl), &wBioBuffer); CHK_ERR(wBioGetMemDataRet != 0, STATUS_SEND_DATA_FAILED, "BIO_get_mem_data failed with: no BIO was connected to the SSL object."); CHK_ERR(wBioGetMemDataRet > 0, STATUS_SEND_DATA_FAILED, "BIO_get_mem_data failed"); - + wBioDataLen = (SIZE_T) wBioGetMemDataRet; if (wBioDataLen > 0) { diff --git a/src/source/Ice/TurnConnection.c b/src/source/Ice/TurnConnection.c index 648524de14..4cb24a5ee6 100644 --- a/src/source/Ice/TurnConnection.c +++ b/src/source/Ice/TurnConnection.c @@ -1055,8 +1055,8 @@ STATUS checkTurnPeerConnections(PTurnConnection pTurnConnection) CHK(pTurnPeer->pTransactionIdStore != NULL, STATUS_INVALID_OPERATION); transactionIdStoreInsert(pTurnPeer->pTransactionIdStore, pTurnConnection->pTurnCreatePermissionPacket->header.transactionId); iceUtilsSendStunPacket(pTurnConnection->pTurnCreatePermissionPacket, pTurnConnection->longTermKey, - ARRAY_SIZE(pTurnConnection->longTermKey), &pTurnConnection->turnServer.ipAddress, - pTurnConnection->pControlChannel, NULL, FALSE); + ARRAY_SIZE(pTurnConnection->longTermKey), &pTurnConnection->turnServer.ipAddress, pTurnConnection->pControlChannel, + NULL, FALSE); } else if (pTurnPeer->connectionState == TURN_PEER_CONN_STATE_BIND_CHANNEL) { if (pTurnPeer->firstTimeBindChannelReq) { @@ -1080,9 +1080,8 @@ STATUS checkTurnPeerConnections(PTurnConnection pTurnConnection) CHK(pTurnPeer->pTransactionIdStore != NULL, STATUS_INVALID_OPERATION); transactionIdStoreInsert(pTurnPeer->pTransactionIdStore, pTurnConnection->pTurnChannelBindPacket->header.transactionId); - iceUtilsSendStunPacket(pTurnConnection->pTurnChannelBindPacket, pTurnConnection->longTermKey, - ARRAY_SIZE(pTurnConnection->longTermKey), &pTurnConnection->turnServer.ipAddress, - pTurnConnection->pControlChannel, NULL, FALSE); + iceUtilsSendStunPacket(pTurnConnection->pTurnChannelBindPacket, pTurnConnection->longTermKey, ARRAY_SIZE(pTurnConnection->longTermKey), + &pTurnConnection->turnServer.ipAddress, pTurnConnection->pControlChannel, NULL, FALSE); } } diff --git a/src/source/Rtcp/RtcpPacket.c b/src/source/Rtcp/RtcpPacket.c index dbcb1086ce..d679919df6 100644 --- a/src/source/Rtcp/RtcpPacket.c +++ b/src/source/Rtcp/RtcpPacket.c @@ -15,7 +15,7 @@ STATUS setRtcpPacketFromBytes(PBYTE pRawPacket, UINT32 pRawPacketsLen, PRtcpPack // We don't assert exact length since this may be a compound packet, it // is the callers responsibility to parse subsequent entries packetLen = getInt16(*(PUINT16) (pRawPacket + RTCP_PACKET_LEN_OFFSET)); - CHK((UINT16)((packetLen + 1) * RTCP_PACKET_LEN_WORD_SIZE) <= pRawPacketsLen, STATUS_RTCP_INPUT_PARTIAL_PACKET); + CHK((UINT16) ((packetLen + 1) * RTCP_PACKET_LEN_WORD_SIZE) <= pRawPacketsLen, STATUS_RTCP_INPUT_PARTIAL_PACKET); pRtcpPacket->header.version = (pRawPacket[0] >> VERSION_SHIFT) & VERSION_MASK; CHK(pRtcpPacket->header.version == RTCP_PACKET_VERSION_VAL, STATUS_RTCP_INPUT_PACKET_INVALID_VERSION); diff --git a/src/source/Sctp/Sctp.c b/src/source/Sctp/Sctp.c index 275837477b..c205f61c2d 100644 --- a/src/source/Sctp/Sctp.c +++ b/src/source/Sctp/Sctp.c @@ -359,7 +359,7 @@ INT32 onSctpInboundPacket(struct socket* sock, union sctp_sockstore addr, PVOID CleanUp: UNUSED_PARAM(retStatus); - + /* * IMPORTANT!!! The allocation is done in the sctp library using default allocator * so we need to use the default free API. diff --git a/src/source/Stun/Stun.c b/src/source/Stun/Stun.c index cc109ed632..14eddd7a06 100644 --- a/src/source/Stun/Stun.c +++ b/src/source/Stun/Stun.c @@ -555,7 +555,7 @@ STATUS deserializeStunPacket(PBYTE pStunBuffer, UINT32 bufferSize, PBYTE passwor magicCookie = (UINT32) getInt32(*(PUINT32) ((PBYTE) pStunHeader + STUN_HEADER_TYPE_LEN + STUN_HEADER_DATA_LEN)); // Validate the specified size - CHK(bufferSize >= (UINT16)(messageLength + STUN_HEADER_LEN), STATUS_INVALID_ARG); + CHK(bufferSize >= (UINT16) (messageLength + STUN_HEADER_LEN), STATUS_INVALID_ARG); // Validate the magic cookie CHK(magicCookie == STUN_HEADER_MAGIC_COOKIE, STATUS_STUN_MAGIC_COOKIE_MISMATCH);