Commit 35970452 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] cifs: annotate OPEN_{REQ,RESP}, endianness bugfix

in assignment to OPEN_REQ ->SecurityFlags we did u8 = cpu_to_le32(v8), which
breaks on big-endian.
Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 10021c53
......@@ -619,20 +619,20 @@ typedef struct smb_com_open_req { /* also handles create */
struct smb_hdr hdr; /* wct = 24 */
__u8 AndXCommand;
__u8 AndXReserved;
__u16 AndXOffset;
__le16 AndXOffset;
__u8 Reserved; /* Must Be Zero */
__u16 NameLength;
__u32 OpenFlags;
__u32 RootDirectoryFid;
__u32 DesiredAccess;
__u64 AllocationSize;
__u32 FileAttributes;
__u32 ShareAccess;
__u32 CreateDisposition;
__u32 CreateOptions;
__u32 ImpersonationLevel;
__le16 NameLength;
__le32 OpenFlags;
__le32 RootDirectoryFid;
__le32 DesiredAccess;
__le64 AllocationSize;
__le32 FileAttributes;
__le32 ShareAccess;
__le32 CreateDisposition;
__le32 CreateOptions;
__le32 ImpersonationLevel;
__u8 SecurityFlags;
__u16 ByteCount;
__le16 ByteCount;
char fileName[1];
} OPEN_REQ;
......@@ -649,19 +649,19 @@ typedef struct smb_com_open_rsp {
struct smb_hdr hdr; /* wct = 34 BB */
__u8 AndXCommand;
__u8 AndXReserved;
__u16 AndXOffset;
__le16 AndXOffset;
__u8 OplockLevel;
__u16 Fid;
__u32 CreateAction;
__u64 CreationTime;
__u64 LastAccessTime;
__u64 LastWriteTime;
__u64 ChangeTime;
__u32 FileAttributes;
__u64 AllocationSize;
__u64 EndOfFile;
__u16 FileType;
__u16 DeviceState;
__le32 CreateAction;
__le64 CreationTime;
__le64 LastAccessTime;
__le64 LastWriteTime;
__le64 ChangeTime;
__le32 FileAttributes;
__le64 AllocationSize;
__le64 EndOfFile;
__le16 FileType;
__le16 DeviceState;
__u8 DirectoryFlag;
__u16 ByteCount; /* bct = 0 */
} OPEN_RSP;
......
......@@ -569,6 +569,7 @@ CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
OPEN_RSP *pSMBr = NULL;
int bytes_returned;
int name_len;
__u16 count;
openRetry:
rc = smb_init(SMB_COM_NT_CREATE_ANDX, 24, tcon, (void **) &pSMB,
......@@ -579,7 +580,7 @@ CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
pSMB->AndXCommand = 0xFF; /* none */
if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
pSMB->ByteCount = 1; /* account for one byte pad to word boundary */
count = 1; /* account for one byte pad to word boundary */
name_len =
cifs_strtoUCS((wchar_t *) (pSMB->fileName + 1),
fileName, 530
......@@ -589,7 +590,7 @@ CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
name_len *= 2;
pSMB->NameLength = cpu_to_le16(name_len);
} else { /* BB improve the check for buffer overruns BB */
pSMB->ByteCount = 0; /* no pad */
count = 0; /* no pad */
name_len = strnlen(fileName, 530);
name_len++; /* trailing null */
pSMB->NameLength = cpu_to_le16(name_len);
......@@ -602,30 +603,29 @@ CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
}
pSMB->DesiredAccess = cpu_to_le32(access_flags);
pSMB->AllocationSize = 0;
pSMB->FileAttributes = ATTR_NORMAL;
pSMB->FileAttributes = cpu_to_le32(ATTR_NORMAL);
/* XP does not handle ATTR_POSIX_SEMANTICS */
/* but it helps speed up case sensitive checks for other
servers such as Samba */
if (tcon->ses->capabilities & CAP_UNIX)
pSMB->FileAttributes |= ATTR_POSIX_SEMANTICS;
pSMB->FileAttributes |= cpu_to_le32(ATTR_POSIX_SEMANTICS);
/* if ((omode & S_IWUGO) == 0)
pSMB->FileAttributes |= ATTR_READONLY;*/
pSMB->FileAttributes |= cpu_to_le32(ATTR_READONLY);*/
/* Above line causes problems due to vfs splitting create into two
pieces - need to set mode after file created not while it is
being created */
pSMB->FileAttributes = cpu_to_le32(pSMB->FileAttributes);
pSMB->ShareAccess = cpu_to_le32(FILE_SHARE_ALL);
pSMB->CreateDisposition = cpu_to_le32(openDisposition);
pSMB->CreateOptions = cpu_to_le32(create_options);
pSMB->ImpersonationLevel = cpu_to_le32(SECURITY_IMPERSONATION); /* BB ??*/
pSMB->SecurityFlags =
cpu_to_le32(SECURITY_CONTEXT_TRACKING | SECURITY_EFFECTIVE_ONLY);
SECURITY_CONTEXT_TRACKING | SECURITY_EFFECTIVE_ONLY;
pSMB->ByteCount += name_len;
pSMB->hdr.smb_buf_length += pSMB->ByteCount;
count += name_len;
pSMB->hdr.smb_buf_length += count;
pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount);
pSMB->ByteCount = cpu_to_le16(count);
/* long_op set to 1 to allow for oplock break timeouts */
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 1);
......
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