Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1640555 > unrolled thread
| Started by | Christophe JAILLET <christophe.jaillet@wanadoo.fr> |
|---|---|
| First post | 2017-05-12 18:00 +0200 |
| Last post | 2017-05-13 03:20 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH V2] SMB2: Fix share type handling Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-05-12 18:00 +0200
Re: [PATCH V2] SMB2: Fix share type handling Steve French <smfrench@gmail.com> - 2017-05-13 03:20 +0200
| From | Christophe JAILLET <christophe.jaillet@wanadoo.fr> |
|---|---|
| Date | 2017-05-12 18:00 +0200 |
| Subject | [PATCH V2] SMB2: Fix share type handling |
| Message-ID | <tGl90-6Ig-27@gated-at.bofh.it> |
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.
Fixes: faaf946a7d5b ("CIFS: Add tree connect/disconnect capability for SMB2")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
V2: use a 'switch' instead of some 'if'
The v1 and related comments are quite old. They can be found at:
http://marc.info/?t=147976541800001&r=1&w=4
---
fs/cifs/smb2pdu.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index e0517f499c38..e4afdaae743f 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -1240,15 +1240,19 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
goto tcon_exit;
}
- if (rsp->ShareType & SMB2_SHARE_TYPE_DISK)
+ switch (rsp->ShareType) {
+ case SMB2_SHARE_TYPE_DISK:
cifs_dbg(FYI, "connection to disk share\n");
- else if (rsp->ShareType & SMB2_SHARE_TYPE_PIPE) {
+ break;
+ case SMB2_SHARE_TYPE_PIPE:
tcon->ipc = true;
cifs_dbg(FYI, "connection to pipe share\n");
- } else if (rsp->ShareType & SMB2_SHARE_TYPE_PRINT) {
- tcon->print = true;
+ break;
+ case SMB2_SHARE_TYPE_PRINT:
+ tcon->ipc = true;
cifs_dbg(FYI, "connection to printer\n");
- } else {
+ break;
+ default:
cifs_dbg(VFS, "unknown share type %d\n", rsp->ShareType);
rc = -EOPNOTSUPP;
goto tcon_error_exit;
--
2.11.0
[toc] | [next] | [standalone]
| From | Steve French <smfrench@gmail.com> |
|---|---|
| Date | 2017-05-13 03:20 +0200 |
| Message-ID | <tGtSV-4Zf-3@gated-at.bofh.it> |
| In reply to | #1640555 |
Merged into cifs-2.6.git for-next
On Fri, May 12, 2017 at 10:59 AM, Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
> 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.
>
> Fixes: faaf946a7d5b ("CIFS: Add tree connect/disconnect capability for SMB2")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> V2: use a 'switch' instead of some 'if'
>
> The v1 and related comments are quite old. They can be found at:
> http://marc.info/?t=147976541800001&r=1&w=4
> ---
> fs/cifs/smb2pdu.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
> index e0517f499c38..e4afdaae743f 100644
> --- a/fs/cifs/smb2pdu.c
> +++ b/fs/cifs/smb2pdu.c
> @@ -1240,15 +1240,19 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
> goto tcon_exit;
> }
>
> - if (rsp->ShareType & SMB2_SHARE_TYPE_DISK)
> + switch (rsp->ShareType) {
> + case SMB2_SHARE_TYPE_DISK:
> cifs_dbg(FYI, "connection to disk share\n");
> - else if (rsp->ShareType & SMB2_SHARE_TYPE_PIPE) {
> + break;
> + case SMB2_SHARE_TYPE_PIPE:
> tcon->ipc = true;
> cifs_dbg(FYI, "connection to pipe share\n");
> - } else if (rsp->ShareType & SMB2_SHARE_TYPE_PRINT) {
> - tcon->print = true;
> + break;
> + case SMB2_SHARE_TYPE_PRINT:
> + tcon->ipc = true;
> cifs_dbg(FYI, "connection to printer\n");
> - } else {
> + break;
> + default:
> cifs_dbg(VFS, "unknown share type %d\n", rsp->ShareType);
> rc = -EOPNOTSUPP;
> goto tcon_error_exit;
> --
> 2.11.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Thanks,
Steve
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web