[SCM] Samba Shared Repository - branch v4-11-test updated

Karolin Seeger kseeger at samba.org
Thu Jun 4 11:48:04 UTC 2020


The branch, v4-11-test has been updated
       via  0f35dbd96c0 s3: libsmbclient: Finish unifing bad iconv behavior across CORE NT1 SMB2 protocols.
       via  daddc6956f6 s3: libsmb: In SMB2 return NT_STATUS_INVALID_NETWORK_RESPONSE if name conversion ended up with a NULL filename.
       via  b8f0a185bba s3: libsmb: In SMB1 old protocol - return NT_STATUS_INVALID_NETWORK_RESPONSE if name conversion ended up with a NULL filename.
       via  f02467bf688 s3: selftest: Add test_smbclient_iconv.sh to check client behavior on bad name conversion.
       via  ac45713a18a s3: selftest: Add share definition [bad_iconv] in fileserver.
      from  d90e5a71c79 winbindd: Fix a use-after-free when winbind clients exit

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-11-test


- Log -----------------------------------------------------------------
commit 0f35dbd96c068d5d9638e2477cf0e5f6dafe8f37
Author: Jeremy Allison <jra at samba.org>
Date:   Mon May 11 15:58:27 2020 -0700

    s3: libsmbclient: Finish unifing bad iconv behavior across CORE NT1 SMB2 protocols.
    
    On bad name conversion, exit the directory listing with an error, but leave the
    connection intact. We were already checking for finfo->name == NULL here,
    but were ignoring it and not reporting an error.
    
    Remove the knownfail.d/bad_iconv file as we now
    behave the same across CORE/NT1/SMB2.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14374
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Tue May 12 21:32:44 UTC 2020 on sn-devel-184
    
    (cherry picked from commit 393da520e43bd3a28feb231bcd9fd5308a3daa4a)
    
    Autobuild-User(v4-11-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-11-test): Thu Jun  4 11:47:26 UTC 2020 on sn-devel-184

commit daddc6956f673e5cf369924c9e4a9963e079aca5
Author: Jeremy Allison <jra at samba.org>
Date:   Mon May 11 12:23:49 2020 -0700

    s3: libsmb: In SMB2 return NT_STATUS_INVALID_NETWORK_RESPONSE if name conversion ended up with a NULL filename.
    
    Can happen if namelen == 0.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14374
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit 753115a8d19f6ac8cd28305748fc6d888679dccc)

commit b8f0a185bba2c6b3263e5ca87ebcc9a5fc23c0f6
Author: Jeremy Allison <jra at samba.org>
Date:   Mon May 11 12:34:10 2020 -0700

    s3: libsmb: In SMB1 old protocol - return NT_STATUS_INVALID_NETWORK_RESPONSE if name conversion ended up with a NULL filename.
    
    Can happen if namelen == 0.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14374
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit b10de0bb64fe022e6b066584013dfb0bdf2ade96)

commit f02467bf688e8ba7ef5dd48dda723314e09f21a5
Author: Jeremy Allison <jra at samba.org>
Date:   Mon May 11 15:37:00 2020 -0700

    s3: selftest: Add test_smbclient_iconv.sh to check client behavior on bad name conversion.
    
    SMB2 and NT1 fail this, CORE already returns NT_STATUS_INVALID_NETWORK_RESPONSE
    on bad conversion.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14374
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (back-ported from commit e016671d34c24c4768df774425ec743b88e30015)

commit ac45713a18aa9f1bfbca3dbd350635e8fbb83a26
Author: Jeremy Allison <jra at samba.org>
Date:   Mon May 11 14:10:54 2020 -0700

    s3: selftest: Add share definition [bad_iconv] in fileserver.
    
    Creates a utf8 valid filename within that is invalid in CP850.
    Useful to test smbclient list directory character set conversions.
    
    https://bugzilla.samba.org/show_bug.cgi?id=14374
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (back-ported from commit a9651d6bc2b6dea8adc859ce21c2431253868887)

-----------------------------------------------------------------------

Summary of changes:
 selftest/target/Samba3.pm                    | 20 +++++++++++
 source3/libsmb/cli_smb2_fnum.c               |  6 ++++
 source3/libsmb/clilist.c                     | 10 ++++--
 source3/script/tests/test_smbclient_iconv.sh | 53 ++++++++++++++++++++++++++++
 source3/selftest/tests.py                    |  7 ++++
 5 files changed, 93 insertions(+), 3 deletions(-)
 create mode 100755 source3/script/tests/test_smbclient_iconv.sh


Changeset truncated at 500 lines:

diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index b6bfcef824d..a15979199f0 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -959,6 +959,9 @@ sub setup_fileserver
 	my $usershare_sharedir="$share_dir/usershares";
 	push(@dirs,$usershare_sharedir);
 
+	my $bad_iconv_sharedir="$share_dir/bad_iconv";
+	push(@dirs, $bad_iconv_sharedir);
+
 	my $fileserver_options = "
 	kernel change notify = yes
 
@@ -1026,6 +1029,12 @@ sub setup_fileserver
 	path = $share_dir
 	comment = force group test
 #	force group = everyone
+
+[bad_iconv]
+	path = $bad_iconv_sharedir
+	comment = smb username is [%U]
+	vfs objects =
+
 [homes]
 	comment = Home directories
 	browseable = No
@@ -1094,6 +1103,17 @@ sub setup_fileserver
         close(VALID_USERS_TARGET);
         chmod 0644, $valid_users_target;
 
+	##
+	## create a valid utf8 filename which is invalid as a CP850 conversion
+	##
+        my $bad_iconv_target = "$bad_iconv_sharedir/\xED\x9F\xBF";
+        unless (open(BAD_ICONV_TARGET, ">$bad_iconv_target")) {
+                warn("Unable to open $bad_iconv_target");
+                return undef;
+        }
+        close(BAD_ICONV_TARGET);
+        chmod 0644, $bad_iconv_target;
+
 	return $vars;
 }
 
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 3fa322c243b..0d79cf693da 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -1269,6 +1269,12 @@ static NTSTATUS parse_finfo_id_both_directory_info(uint8_t *dir_data,
 		/* Bad conversion. */
 		return NT_STATUS_INVALID_NETWORK_RESPONSE;
 	}
+
+	if (finfo->name == NULL) {
+		/* Bad conversion. */
+		return NT_STATUS_INVALID_NETWORK_RESPONSE;
+	}
+
 	return NT_STATUS_OK;
 }
 
diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c
index 4f518339e2b..a14bae691b1 100644
--- a/source3/libsmb/clilist.c
+++ b/source3/libsmb/clilist.c
@@ -552,7 +552,10 @@ static NTSTATUS cli_list_old_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
 			TALLOC_FREE(finfo);
 			return NT_STATUS_NO_MEMORY;
 		}
-
+		if (finfo->name == NULL) {
+			TALLOC_FREE(finfo);
+			return NT_STATUS_INVALID_NETWORK_RESPONSE;
+		}
 		status = is_bad_finfo_name(state->cli, finfo);
 		if (!NT_STATUS_IS_OK(status)) {
 			smbXcli_conn_disconnect(state->cli->conn, status);
@@ -791,8 +794,9 @@ static void cli_list_trans_done(struct tevent_req *subreq)
 		if (finfo->name == NULL) {
 			DEBUG(1, ("cli_list: Error: unable to parse name from "
 				  "info level %d\n", state->info_level));
-			ff_eos = true;
-			break;
+			tevent_req_nterror(req,
+				NT_STATUS_INVALID_NETWORK_RESPONSE);
+			return;
 		}
 
 		status = is_bad_finfo_name(state->cli, finfo);
diff --git a/source3/script/tests/test_smbclient_iconv.sh b/source3/script/tests/test_smbclient_iconv.sh
new file mode 100755
index 00000000000..0ec7b67dbf7
--- /dev/null
+++ b/source3/script/tests/test_smbclient_iconv.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+# This checks directory listing with a file containing
+# an invalid CP850 conversion name returns NT_STATUS_INVALID_NETWORK_RESPONSE
+
+if [ $# -lt 6 ]; then
+cat <<EOF
+Usage: test_smbclient_iconv.sh SERVER SERVER_IP SHARENAME USERNAME PASSWORD SMBCLIENT
+EOF
+exit 1;
+fi
+
+SERVER="$1"
+SERVER_IP="$2"
+SHARENAME="$3"
+USERNAME="$4"
+PASSWORD="$5"
+SMBCLIENT="$6"
+shift 6
+ADDARGS="$@"
+
+incdir=`dirname $0`/../../../testprogs/blackbox
+. $incdir/subunit.sh
+
+failed=0
+
+test_smbclient_iconv()
+{
+    smbclient_config="$PREFIX/client/client_cp850_smbconf"
+    cat > $smbclient_config <<EOF
+[global]
+    unix charset = cp850
+    client min protocol = core
+EOF
+
+    cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT -U$USERNAME%$PASSWORD //$SERVER/$SHARENAME --configfile=$smbclient_config "$ADDARGS" -c ls 2>&1'
+    eval echo "$cmd"
+    out=$(eval $cmd)
+    rm -f $smbclient_config
+
+    echo "$out" | grep 'NT_STATUS_INVALID_NETWORK_RESPONSE'
+    ret=$?
+    if [ $ret -ne 0 ] ; then
+       echo "$out"
+       echo 'failed - should get: NT_STATUS_INVALID_NETWORK_RESPONSE.'
+       return 1
+    fi
+
+    return 0
+}
+
+testit "bad_iconv smbclient" test_smbclient_iconv || failed=$(expr $failed + 1)
+testok $0 $failed
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 5c43e6e9458..98f372c95e9 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -354,6 +354,13 @@ for env in ["fileserver"]:
                   [os.path.join(samba3srcdir, "script/tests/test_zero_data.sh"),
                    '$SERVER_IP', '$USERNAME', '$PASSWORD', '$LOCAL_PATH'])
 
+    plantestsuite("samba3.blackbox.smbclient_iconv.SMB2", env,
+                  [os.path.join(samba3srcdir, "script/tests/test_smbclient_iconv.sh"),
+                   '$SERVER', '$SERVER_IP', 'bad_iconv', '$USERNAME', '$PASSWORD', smbclient3])
+    plantestsuite("samba3.blackbox.smbclient_iconv.NT1", env,
+                  [os.path.join(samba3srcdir, "script/tests/test_smbclient_iconv.sh"),
+                   '$SERVER', '$SERVER_IP', 'bad_iconv', '$USERNAME', '$PASSWORD', smbclient3, '-mNT1'])
+
     #
     # tar command tests
     #


-- 
Samba Shared Repository



More information about the samba-cvs mailing list