The branch, master has been updated via f30f5793ad5 libsmb: Fix directory listing against old servers via e86234f3d61 tests: Show that we 100% loop in cli_list_old_recv() via 4804d6b89a9 tests: Make timelimit available to test scripts from 52cb127f16a docs: fix a typo in history file
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit f30f5793ad592e193546586b765837c0ac9f5647 Author: Volker Lendecke <v...@samba.org> Date: Thu Jun 1 15:57:26 2023 +0200 libsmb: Fix directory listing against old servers cli_list_trans_recv() can be called multiple times. When it's done, it return NT_STATUS_OK and set *finfo to NULL. cli_list_old_recv() did not do the NULL part, so smbclient would endlessly loop. Bug: https://bugzilla.samba.org/show_bug.cgi?id=15382 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Thu Jun 1 21:54:42 UTC 2023 on atb-devel-224 commit e86234f3d61c62e4365e1ea105bdd29feaf7ccbe Author: Volker Lendecke <v...@samba.org> Date: Thu Jun 1 16:41:37 2023 +0200 tests: Show that we 100% loop in cli_list_old_recv() Bug: https://bugzilla.samba.org/show_bug.cgi?id=15382 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 4804d6b89a9146f1fc5270de158cd25254505f61 Author: Volker Lendecke <v...@samba.org> Date: Thu Jun 1 16:39:21 2023 +0200 tests: Make timelimit available to test scripts Bug: https://bugzilla.samba.org/show_bug.cgi?id=15382 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> ----------------------------------------------------------------------- Summary of changes: selftest/selftesthelpers.py | 1 + source3/libsmb/clilist.c | 6 ++++++ source3/script/tests/test_old_dirlisting.sh | 28 ++++++++++++++++++++++++++++ source3/selftest/tests.py | 6 ++++++ 4 files changed, 41 insertions(+) create mode 100755 source3/script/tests/test_old_dirlisting.sh Changeset truncated at 500 lines: diff --git a/selftest/selftesthelpers.py b/selftest/selftesthelpers.py index 951eeb4d1b5..908fe79cb19 100644 --- a/selftest/selftesthelpers.py +++ b/selftest/selftesthelpers.py @@ -236,3 +236,4 @@ rpcclient = binpath('rpcclient') smbcacls = binpath('smbcacls') smbcontrol = binpath('smbcontrol') smbstatus = binpath('smbstatus') +timelimit = binpath('timelimit') diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c index 903c5d22777..58a8fe1a0c6 100644 --- a/source3/libsmb/clilist.c +++ b/source3/libsmb/clilist.c @@ -544,6 +544,11 @@ static NTSTATUS cli_list_old_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, return status; } + if (state->dirlist == NULL) { + *pfinfo = NULL; + return NT_STATUS_OK; + } + num_received = talloc_array_length(state->dirlist) / DIR_STRUCT_SIZE; finfo = talloc_array(mem_ctx, struct file_info, num_received); @@ -570,6 +575,7 @@ static NTSTATUS cli_list_old_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, return status; } } + TALLOC_FREE(state->dirlist); *pfinfo = finfo; return NT_STATUS_OK; } diff --git a/source3/script/tests/test_old_dirlisting.sh b/source3/script/tests/test_old_dirlisting.sh new file mode 100755 index 00000000000..f50a4742b1a --- /dev/null +++ b/source3/script/tests/test_old_dirlisting.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# This tests listing directories using the SMBSearch call family + +if [ $# -lt 2 ]; then + cat <<EOF +Usage: $0 TIMELIMIT SMBCLIENT +EOF + exit 1 +fi + +TIMELIMIT="$1" +shift +SMBCLIENT="$VALGRIND $1" +shift + +incdir=$(dirname $0)/../../../testprogs/blackbox +. $incdir/subunit.sh + +# Make sure we don't loop 100% CPU. A normal dir listing should return +# in less than 3 seconds. At the point of this commit smbclient -c dir +# | wc returns 43 lines, so checking for 100 lines should be well +# enough. + +count=$($TIMELIMIT 3 $SMBCLIENT //"$SERVER_IP"/tmpguest -m LANMAN1 -U% \ + -c dir | wc -l) + +testit "listing shares with LANMAN1" test ${count} -le 100 || + failed=$((failed + 1)) diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index 76bc90df1ad..75acbf87442 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -34,6 +34,7 @@ from selftesthelpers import valgrindify, smbtorture4_testsuites from selftesthelpers import smbtorture4_options from selftesthelpers import smbcontrol from selftesthelpers import smbstatus +from selftesthelpers import timelimit smbtorture4_options.extend([ '--option=torture:sharedelay=100000', '--option=torture:writetimeupdatedelay=500000', @@ -829,6 +830,11 @@ for env in ["fileserver"]: '$SERVER', 'fruit_resource_stream', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/fruit_resource_stream', smbclient3]) +plantestsuite("samba3.blackbox.smbclient_old_dir", "fileserver_smb1", + [os.path.join(samba3srcdir, + "script/tests/test_old_dirlisting.sh"), + timelimit, smbclient3]) + for env in ["fileserver:local"]: plantestsuite("samba3.blackbox.net_usershare", env, [os.path.join(samba3srcdir, "script/tests/test_net_usershare.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', smbclient3]) -- Samba Shared Repository