From 1e982a7a22e845131da887d67866a3e82171ace8 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Thu, 15 Feb 2024 06:07:10 -0700 Subject: [PATCH 1/2] fix for file offset when larger than word32 size --- src/internal.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/internal.c b/src/internal.c index 8c710d193..e7020fbfc 100644 --- a/src/internal.c +++ b/src/internal.c @@ -14379,7 +14379,9 @@ void AddAssign64(word32* addend1, word32 addend2) { if (addend1[0] > (WOLFSSL_MAX_32BIT - addend2)) { addend1[1]++; - addend1[0] = addend2 - (WOLFSSL_MAX_32BIT- addend1[0]); + + /* -1 to account for roll over digit */ + addend1[0] = addend2 - (WOLFSSL_MAX_32BIT- addend1[0]) - 1; } else { addend1[0] += addend2; From cd3130fa7e23fa736fc6775a2984a770d2d87934 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Thu, 15 Feb 2024 09:32:58 -0700 Subject: [PATCH 2/2] add large sftp file transfer test case --- .github/workflows/sshd-test.yml | 2 +- apps/wolfsshd/test/run_all_sshd_tests.sh | 1 + apps/wolfsshd/test/sshd_large_sftp_test.sh | 40 ++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100755 apps/wolfsshd/test/sshd_large_sftp_test.sh diff --git a/.github/workflows/sshd-test.yml b/.github/workflows/sshd-test.yml index 828344af8..1a715ccc5 100644 --- a/.github/workflows/sshd-test.yml +++ b/.github/workflows/sshd-test.yml @@ -22,7 +22,7 @@ jobs: - name: autogen run: ./autogen.sh - name: configure - run: ./configure --enable-all CPPFLAGS=-DWOLFSSH_NO_FPKI + run: ./configure --enable-all CPPFLAGS="-DWOLFSSH_NO_FPKI -DWOLFSSH_NO_SFTP_TIMEOUT -DWOLFSSH_MAX_SFTP_RW=4000000" - name: make run: make - name: make check diff --git a/apps/wolfsshd/test/run_all_sshd_tests.sh b/apps/wolfsshd/test/run_all_sshd_tests.sh index 746762bb7..d103939c4 100755 --- a/apps/wolfsshd/test/run_all_sshd_tests.sh +++ b/apps/wolfsshd/test/run_all_sshd_tests.sh @@ -59,6 +59,7 @@ run_test() { run_test "sshd_exec_test.sh" run_test "sshd_term_size_test.sh" +run_test "sshd_large_sftp_test.sh" #Github actions needs resolved for these test cases #run_test "error_return.sh" diff --git a/apps/wolfsshd/test/sshd_large_sftp_test.sh b/apps/wolfsshd/test/sshd_large_sftp_test.sh new file mode 100755 index 000000000..0a3144273 --- /dev/null +++ b/apps/wolfsshd/test/sshd_large_sftp_test.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +# sshd local test + +PWD=`pwd` +cd ../../.. + +TEST_SFTP_CLIENT="./examples/sftpclient/wolfsftp" +USER=`whoami` +PRIVATE_KEY="./keys/hansel-key-ecc.der" +PUBLIC_KEY="./keys/hansel-key-ecc.pub" + +if [ -z "$1" ] || [ -z "$2" ]; then + echo "expecting host and port as arguments" + echo "./sshd_exec_test.sh 127.0.0.1 22222" + exit 1 +fi + + +# create a large file with random data (larger than word32 max value) +head -c 4400000010 < /dev/random > large-random.txt + +set -e +echo "$TEST_SFTP_CLIENT -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -g -l large-random.txt -r `pwd`/large-random-2.txt -h \"$1\" -p \"$2\"" +$TEST_SFTP_CLIENT -u $USER -i $PRIVATE_KEY -j $PUBLIC_KEY -g -l large-random.txt -r `pwd`/large-random-2.txt -h "$1" -p "$2" + +cmp large-random.txt large-random-2.txt +RESULT=$? +if [ "$RESULT" != "0" ]; then + echo "files did not match when compared" + exit 1 +fi +rm -f large-random.txt +rm -f large-random-2.txt + +set +e + +cd $PWD +exit 0 +