s3: libsmb: Fix cli_state_has_tcon() to cope with SMB2 connections.
authorJeremy Allison <jra@samba.org>
Tue, 13 Jun 2017 23:36:54 +0000 (16:36 -0700)
committerJeremy Allison <jra@samba.org>
Sat, 17 Jun 2017 04:39:20 +0000 (06:39 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12831

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
source3/libsmb/clientgen.c

index 25f7299195677244ab59411f81eeb5264529231c..4541763ea3f2ce4bebc41629ad3530b4b68b4f1d 100644 (file)
@@ -341,12 +341,24 @@ uint32_t cli_getpid(struct cli_state *cli)
 
 bool cli_state_has_tcon(struct cli_state *cli)
 {
-       uint32_t tid = cli_state_get_tid(cli);
-
-       if (tid == UINT16_MAX) {
-               return false;
+       uint32_t tid;
+       if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
+               if (cli->smb2.tcon == NULL) {
+                       return false;
+               }
+               tid = cli_state_get_tid(cli);
+               if (tid == UINT32_MAX) {
+                       return false;
+               }
+       } else {
+               if (cli->smb1.tcon == NULL) {
+                       return false;
+               }
+               tid = cli_state_get_tid(cli);
+               if (tid == UINT16_MAX) {
+                       return false;
+               }
        }
-
        return true;
 }