All of lore.kernel.org
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
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
Date: Tue, 22 Nov 2016 08:19:42 +0000	[thread overview]
Message-ID: <5833FF9E.1030707@bfs.de> (raw)
In-Reply-To: <20161121215352.3183-1-christophe.jaillet@wanadoo.fr>



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 <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 {


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:

WARNING: multiple messages have this Message-ID (diff)
From: walter harms <wharms@bfs.de>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
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
Date: Tue, 22 Nov 2016 09:19:42 +0100	[thread overview]
Message-ID: <5833FF9E.1030707@bfs.de> (raw)
In-Reply-To: <20161121215352.3183-1-christophe.jaillet@wanadoo.fr>



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 <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 {


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:

  reply	other threads:[~2016-11-22  8:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-21 21:53 [PATCH] SMB2: Fix share type handling Christophe JAILLET
2016-11-21 21:53 ` Christophe JAILLET
2016-11-22  8:19 ` walter harms [this message]
2016-11-22  8:19   ` walter harms
     [not found] ` <20161121215352.3183-1-christophe.jaillet-39ZsbGIQGT5GWvitb5QawA@public.gmane.org>
2016-11-22 12:18   ` Aurélien Aptel
2016-11-22 12:18     ` Aurélien Aptel
2016-11-22 12:18     ` Aurélien Aptel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5833FF9E.1030707@bfs.de \
    --to=wharms@bfs.de \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samba-technical@lists.samba.org \
    --cc=sfrench@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.