Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755553AbcKVITu (ORCPT ); Tue, 22 Nov 2016 03:19:50 -0500 Received: from mx01-fr.bfs.de ([193.174.231.67]:18752 "EHLO mx01-fr.bfs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752817AbcKVITr (ORCPT ); Tue, 22 Nov 2016 03:19:47 -0500 Message-ID: <5833FF9E.1030707@bfs.de> Date: Tue, 22 Nov 2016 09:19:42 +0100 From: walter harms Reply-To: wharms@bfs.de User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.1.16) Gecko/20101125 SUSE/3.0.11 Thunderbird/3.0.11 MIME-Version: 1.0 To: Christophe JAILLET CC: sfrench@samba.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] SMB2: Fix share type handling References: <20161121215352.3183-1-christophe.jaillet@wanadoo.fr> In-Reply-To: <20161121215352.3183-1-christophe.jaillet@wanadoo.fr> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2050 Lines: 68 Am 21.11.2016 22:53, schrieb Christophe JAILLET: > 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 > --- > 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 { perhaps a switch/case is better suited for this ? looks more readable. re, wh switch(sp->ShareType ) { case SMB2_SHARE_TYPE_DISK: cifs_dbg(FYI, "connection to disk share\n"); break; case SMB2_SHARE_TYPE_PIPE: tcon->ipc = true; cifs_dbg(FYI, "connection to pipe share\n"); break; case SMB2_SHARE_TYPE_PRINT: tcon->ipc = true; cifs_dbg(FYI, "connection to printer\n"); break; default: