From: Jeremy Allison Date: Tue, 13 Jun 2017 23:36:54 +0000 (-0700) Subject: s3: libsmb: Fix cli_state_has_tcon() to cope with SMB2 connections. X-Git-Tag: samba-4.5.11~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d0d9820531aca17a5300f4e4eb47f07a999aaca;p=thirdparty%2Fsamba.git s3: libsmb: Fix cli_state_has_tcon() to cope with SMB2 connections. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12831 Signed-off-by: Jeremy Allison Reviewed-by: Richard Sharpe (cherry picked from commit c9178ed9cc69b9089292db28ac1a0b7a0519bc2c) --- diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 25f72991956..4541763ea3f 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -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; }