From 38163b15ff02ba6545a128ec88ba0bfa6cc455d3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 29 Oct 2019 12:11:01 -0700 Subject: [PATCH 1/2] s3: libsmb: Ensure we don't call cli_RNetShareEnum() on an SMB1 connection. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14174 Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme (cherry picked from commit 1cfcad6283da855d3e97237a7a6fd6f4d2436ee2) --- source3/libsmb/libsmb_dir.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c index df606c4adfe..ab20a127c49 100644 --- a/source3/libsmb/libsmb_dir.c +++ b/source3/libsmb/libsmb_dir.c @@ -856,7 +856,12 @@ SMBC_opendir_ctx(SMBCCTX *context, list_fn, (void *)dir); if (rc != 0 && - lp_client_min_protocol() <= PROTOCOL_NT1) { + smbXcli_conn_protocol(srv->cli->conn) <= + PROTOCOL_NT1) { + /* + * Only call cli_RNetShareEnum() + * on SMB1 connections, not SMB2+. + */ rc = cli_RNetShareEnum(srv->cli, list_fn, (void *)dir); -- 2.24.0.rc1.363.gb1bccd3e3d-goog From 83a9a96a120d07b6f15e08fcbc850af8268c02cc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 29 Oct 2019 12:11:49 -0700 Subject: [PATCH 2/2] s3: utils: smbtree. Ensure we don't call cli_RNetShareEnum() on an SMB1 connection. Last unprotected call of cli_RNetShareEnum(). Not a libsmbclient bug here but might as well fix the last caller as part of the fix for the bug. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14174 Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme (cherry picked from commit f30b8b3aa1309e9daeb9a3601b537dead81e5dbb) --- source3/utils/smbtree.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c index 9f589b4060f..de32924489f 100644 --- a/source3/utils/smbtree.c +++ b/source3/utils/smbtree.c @@ -26,6 +26,7 @@ #include "libsmb/libsmb.h" #include "libsmb/namequery.h" #include "libsmb/clirap.h" +#include "../libcli/smb/smbXcli_base.h" static int use_bcast; @@ -231,6 +232,10 @@ static bool get_shares(char *server_name, const struct user_auth_info *user_info if (get_rpc_shares(cli, add_name, &shares)) return True; + if (smbXcli_conn_protocol(cli->conn) > PROTOCOL_NT1) { + return false; + } + if (!cli_RNetShareEnum(cli, add_name, &shares)) return False; -- 2.24.0.rc1.363.gb1bccd3e3d-goog