From 5fe0579846e5ccc1d0ad27a1042f67de73778405 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 22 Dec 2022 10:36:02 +0100 Subject: [PATCH 1/2] s3:script: Improve test_chdir_cache.sh BUG: https://bugzilla.samba.org/show_bug.cgi?id=15268 Signed-off-by: Andreas Schneider Reviewed-by: Ralph Boehme (cherry picked from commit 0d1961267cd9e8f1158a407c5d135514c363f37e) --- source3/script/tests/test_chdir_cache.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source3/script/tests/test_chdir_cache.sh b/source3/script/tests/test_chdir_cache.sh index ae244acdd58..c649d2b07b3 100755 --- a/source3/script/tests/test_chdir_cache.sh +++ b/source3/script/tests/test_chdir_cache.sh @@ -33,7 +33,7 @@ conf_dir=$(dirname ${SERVERCONFFILE}) log_file=${conf_dir}/../smbd_test.log error_inject_conf=${conf_dir}/error_inject.conf ->${error_inject_conf} +rm -f ${error_inject_conf} incdir=$(dirname $0)/../../../testprogs/blackbox . $incdir/subunit.sh @@ -80,7 +80,9 @@ head -n 4 <&101 # Ensure any chdir will give EACCESS. echo "error_inject:chdir = EACCES" >${error_inject_conf} -${SMBCONTROL} ${CONF} 0 reload-config +testit "reload config 1" \ + "${SMBCONTROL}" "${CONF}" smbd reload-config || + failed=$((failed + 1)) sleep 1 @@ -94,8 +96,10 @@ kill ${CLIENT_PID} rm -f smbclient-stdin smbclient-stdout smbclient-stderr # Remove the chdir inject. ->${error_inject_conf} -${SMBCONTROL} ${CONF} 0 reload-config +rm -f ${error_inject_conf} +testit "reload config 2" \ + "${SMBCONTROL}" "${CONF}" smbd reload-config || + failed=$((failed + 1)) # Now look for chdir_current_service: vfs_ChDir.*failed: Permission denied # in the smb log. There should be one more than before. -- 2.39.0 From 775a1ca7591804474dcc3dd593533307b2120a51 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 22 Dec 2022 10:31:11 +0100 Subject: [PATCH 2/2] s3:client: Fix a use-after-free issue in smbclient Detected by make test TESTS="samba3.blackbox.chdir-cache" with an optimized build or with AddressSanitizer. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15268 Signed-off-by: Andreas Schneider Reviewed-by: Ralph Boehme (cherry picked from commit 9c707b4be27e2a6f79886d3ec8b5066c922b99bd) --- source3/client/client.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source3/client/client.c b/source3/client/client.c index 651da5fbf7a..613fa4fd1f6 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -5126,10 +5126,11 @@ static int cmd_tcon(void) return -1; } - talloc_free(sharename); - d_printf("tcon to %s successful, tid: %u\n", sharename, cli_state_get_tid(cli)); + + talloc_free(sharename); + return 0; } -- 2.39.0