Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1527069

[PATCH] SMB2: Fix share type handling

From Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Newsgroups linux.kernel
Subject [PATCH] SMB2: Fix share type handling
Date 2016-11-21 23:00 +0100
Message-ID <sG4N4-6GD-9@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


In fs/cifs/smb2pdu.h, we have:
#define SMB2_SHARE_TYPE_DISK    0x01
#define SMB2_SHARE_TYPE_PIPE    0x02
#define SMB2_SHARE_TYPE_PRINT   0x03

Knowing that, with the current code, the SMB2_SHARE_TYPE_PRINT case can
never trigger and printer share would be interpreted as disk share.

So, test the ShareType value for equality instead.

While at it, add some { } to fix a small style issue.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile-tested only.

The proposed patch changes a bit the semantic as no masking is performed
anymore. If some upper bits in 'ShareType' are set, it would now be rejected
instead of silently accepted.
---
 fs/cifs/smb2pdu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 5ca5ea4668a1..600f52994fd9 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -1143,12 +1143,12 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
 		goto tcon_exit;
 	}
 
-	if (rsp->ShareType & SMB2_SHARE_TYPE_DISK)
+	if (rsp->ShareType == SMB2_SHARE_TYPE_DISK) {
 		cifs_dbg(FYI, "connection to disk share\n");
-	else if (rsp->ShareType & SMB2_SHARE_TYPE_PIPE) {
+	} else if (rsp->ShareType == SMB2_SHARE_TYPE_PIPE) {
 		tcon->ipc = true;
 		cifs_dbg(FYI, "connection to pipe share\n");
-	} else if (rsp->ShareType & SMB2_SHARE_TYPE_PRINT) {
+	} else if (rsp->ShareType == SMB2_SHARE_TYPE_PRINT) {
 		tcon->print = true;
 		cifs_dbg(FYI, "connection to printer\n");
 	} else {
-- 
2.9.3

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] SMB2: Fix share type handling Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2016-11-21 23:00 +0100
  Re: [PATCH] SMB2: Fix share type handling walter harms <wharms@bfs.de> - 2016-11-22 09:30 +0100
  Re: [PATCH] SMB2: Fix share type handling Aurélien Aptel <aaptel@suse.com> - 2016-11-22 13:20 +0100

csiph-web