Commit 928e5846 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] cifs: annotate TCONX_{REQ,RESP}

Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 53cb19c4
...@@ -328,7 +328,7 @@ struct smb_hdr { ...@@ -328,7 +328,7 @@ struct smb_hdr {
#define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) ) ) #define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) ) )
/* given a pointer to an smb_hdr retrieve the pointer to the byte area */ /* given a pointer to an smb_hdr retrieve the pointer to the byte area */
#define pByteArea(smb_var) ((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) + 2 ) #define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) + 2 )
/* /*
* Computer Name Length * Computer Name Length
...@@ -537,10 +537,10 @@ typedef struct smb_com_tconx_req { ...@@ -537,10 +537,10 @@ typedef struct smb_com_tconx_req {
struct smb_hdr hdr; /* wct = 4 */ struct smb_hdr hdr; /* wct = 4 */
__u8 AndXCommand; __u8 AndXCommand;
__u8 AndXReserved; __u8 AndXReserved;
__u16 AndXOffset; __le16 AndXOffset;
__u16 Flags; /* see below */ __le16 Flags; /* see below */
__u16 PasswordLength; __le16 PasswordLength;
__u16 ByteCount; __le16 ByteCount;
unsigned char Password[1]; /* followed by */ unsigned char Password[1]; /* followed by */
/* STRING Path *//* \\server\share name */ /* STRING Path *//* \\server\share name */
/* STRING Service */ /* STRING Service */
...@@ -550,8 +550,8 @@ typedef struct smb_com_tconx_rsp { ...@@ -550,8 +550,8 @@ typedef struct smb_com_tconx_rsp {
struct smb_hdr hdr; /* wct = 3 *//* note that Win2000 has sent wct=7 in some cases on responses. Four unspecified words followed OptionalSupport */ struct smb_hdr hdr; /* wct = 3 *//* note that Win2000 has sent wct=7 in some cases on responses. Four unspecified words followed OptionalSupport */
__u8 AndXCommand; __u8 AndXCommand;
__u8 AndXReserved; __u8 AndXReserved;
__u16 AndXOffset; __le16 AndXOffset;
__u16 OptionalSupport; /* see below */ __le16 OptionalSupport; /* see below */
__u16 ByteCount; __u16 ByteCount;
unsigned char Service[1]; /* always ASCII, not Unicode */ unsigned char Service[1]; /* always ASCII, not Unicode */
/* STRING NativeFileSystem */ /* STRING NativeFileSystem */
......
...@@ -2747,9 +2747,10 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2747,9 +2747,10 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
struct smb_hdr *smb_buffer_response; struct smb_hdr *smb_buffer_response;
TCONX_REQ *pSMB; TCONX_REQ *pSMB;
TCONX_RSP *pSMBr; TCONX_RSP *pSMBr;
char *bcc_ptr; unsigned char *bcc_ptr;
int rc = 0; int rc = 0;
int length; int length;
__u16 count;
if (ses == NULL) if (ses == NULL)
return -EIO; return -EIO;
...@@ -2769,7 +2770,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2769,7 +2770,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
pSMB->AndXCommand = 0xFF; pSMB->AndXCommand = 0xFF;
pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO); pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO);
pSMB->PasswordLength = cpu_to_le16(1); /* minimum */ pSMB->PasswordLength = cpu_to_le16(1); /* minimum */
bcc_ptr = &(pSMB->Password[0]); bcc_ptr = &pSMB->Password[0];
bcc_ptr++; /* skip password */ bcc_ptr++; /* skip password */
if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
...@@ -2795,16 +2796,16 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2795,16 +2796,16 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
strcpy(bcc_ptr, "?????"); strcpy(bcc_ptr, "?????");
bcc_ptr += strlen("?????"); bcc_ptr += strlen("?????");
bcc_ptr += 1; bcc_ptr += 1;
BCC(smb_buffer) = (long) bcc_ptr - (long) pByteArea(smb_buffer); count = bcc_ptr - &pSMB->Password[0];
smb_buffer->smb_buf_length += BCC(smb_buffer); pSMB->hdr.smb_buf_length += count;
BCC(smb_buffer) = cpu_to_le16(BCC(smb_buffer)); pSMB->ByteCount = cpu_to_le16(count);
rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, &length, 0); rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, &length, 0);
/* if (rc) rc = map_smb_to_linux_error(smb_buffer_response); */ /* if (rc) rc = map_smb_to_linux_error(smb_buffer_response); */
/* above now done in SendReceive */ /* above now done in SendReceive */
if ((rc == 0) && (tcon != NULL)) { if ((rc == 0) && (tcon != NULL)) {
tcon->tidStatus = CifsGood; tcon->tidStatus = CifsGood;
tcon->tid = smb_buffer_response->Tid; tcon->tid = smb_buffer_response->Tid;
bcc_ptr = pByteArea(smb_buffer_response); bcc_ptr = pByteArea(smb_buffer_response);
length = strnlen(bcc_ptr, BCC(smb_buffer_response) - 2); length = strnlen(bcc_ptr, BCC(smb_buffer_response) - 2);
...@@ -2813,8 +2814,8 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2813,8 +2814,8 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
strncpy(tcon->treeName, tree, MAX_TREE_SIZE); strncpy(tcon->treeName, tree, MAX_TREE_SIZE);
if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { if (smb_buffer->Flags2 & SMBFLG2_UNICODE) {
length = UniStrnlen((wchar_t *) bcc_ptr, 512); length = UniStrnlen((wchar_t *) bcc_ptr, 512);
if (((long) bcc_ptr + (2 * length)) - if ((bcc_ptr + (2 * length)) -
(long) pByteArea(smb_buffer_response) <= pByteArea(smb_buffer_response) <=
BCC(smb_buffer_response)) { BCC(smb_buffer_response)) {
if(tcon->nativeFileSystem) if(tcon->nativeFileSystem)
kfree(tcon->nativeFileSystem); kfree(tcon->nativeFileSystem);
...@@ -2831,8 +2832,8 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2831,8 +2832,8 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
/* else do not bother copying these informational fields */ /* else do not bother copying these informational fields */
} else { } else {
length = strnlen(bcc_ptr, 1024); length = strnlen(bcc_ptr, 1024);
if (((long) bcc_ptr + length) - if ((bcc_ptr + length) -
(long) pByteArea(smb_buffer_response) <= pByteArea(smb_buffer_response) <=
BCC(smb_buffer_response)) { BCC(smb_buffer_response)) {
if(tcon->nativeFileSystem) if(tcon->nativeFileSystem)
kfree(tcon->nativeFileSystem); kfree(tcon->nativeFileSystem);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment