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

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

Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 6e9e9e24
...@@ -1090,40 +1090,40 @@ typedef union smb_com_transaction2 { ...@@ -1090,40 +1090,40 @@ typedef union smb_com_transaction2 {
typedef struct smb_com_transaction2_qpi_req { typedef struct smb_com_transaction2_qpi_req {
struct smb_hdr hdr; /* wct = 14+ */ struct smb_hdr hdr; /* wct = 14+ */
__u16 TotalParameterCount; __le16 TotalParameterCount;
__u16 TotalDataCount; __le16 TotalDataCount;
__u16 MaxParameterCount; __le16 MaxParameterCount;
__u16 MaxDataCount; __le16 MaxDataCount;
__u8 MaxSetupCount; __u8 MaxSetupCount;
__u8 Reserved; __u8 Reserved;
__u16 Flags; __le16 Flags;
__u32 Timeout; __le32 Timeout;
__u16 Reserved2; __u16 Reserved2;
__u16 ParameterCount; __le16 ParameterCount;
__u16 ParameterOffset; __le16 ParameterOffset;
__u16 DataCount; __le16 DataCount;
__u16 DataOffset; __le16 DataOffset;
__u8 SetupCount; __u8 SetupCount;
__u8 Reserved3; __u8 Reserved3;
__u16 SubCommand; /* one setup word */ __le16 SubCommand; /* one setup word */
__u16 ByteCount; __le16 ByteCount;
__u8 Pad; __u8 Pad;
__u16 InformationLevel; __le16 InformationLevel;
__u32 Reserved4; __u32 Reserved4;
char FileName[1]; char FileName[1];
} TRANSACTION2_QPI_REQ; } TRANSACTION2_QPI_REQ;
typedef struct smb_com_transaction2_qpi_rsp { typedef struct smb_com_transaction2_qpi_rsp {
struct smb_hdr hdr; /* wct = 10 + SetupCount */ struct smb_hdr hdr; /* wct = 10 + SetupCount */
__u16 TotalParameterCount; __le16 TotalParameterCount;
__u16 TotalDataCount; __le16 TotalDataCount;
__u16 Reserved; __le16 Reserved;
__u16 ParameterCount; __le16 ParameterCount;
__u16 ParameterOffset; __le16 ParameterOffset;
__u16 ParameterDisplacement; __le16 ParameterDisplacement;
__u16 DataCount; __le16 DataCount;
__u16 DataOffset; __le16 DataOffset;
__u16 DataDisplacement; __le16 DataDisplacement;
__u8 SetupCount; __u8 SetupCount;
__u8 Reserved1; /* should be zero setup words following */ __u8 Reserved1; /* should be zero setup words following */
__u16 ByteCount; __u16 ByteCount;
......
...@@ -1380,6 +1380,7 @@ CIFSSMBUnixQuerySymLink(const int xid, struct cifsTconInfo *tcon, ...@@ -1380,6 +1380,7 @@ CIFSSMBUnixQuerySymLink(const int xid, struct cifsTconInfo *tcon,
int rc = 0; int rc = 0;
int bytes_returned; int bytes_returned;
int name_len; int name_len;
__u16 params, byte_count;
cFYI(1, ("In QPathSymLinkInfo (Unix) for path %s", searchName)); cFYI(1, ("In QPathSymLinkInfo (Unix) for path %s", searchName));
...@@ -1402,8 +1403,7 @@ CIFSSMBUnixQuerySymLink(const int xid, struct cifsTconInfo *tcon, ...@@ -1402,8 +1403,7 @@ CIFSSMBUnixQuerySymLink(const int xid, struct cifsTconInfo *tcon,
strncpy(pSMB->FileName, searchName, name_len); strncpy(pSMB->FileName, searchName, name_len);
} }
pSMB->TotalParameterCount = params = 2 /* level */ + 4 /* rsrvd */ + name_len /* incl null */ ;
2 /* level */ + 4 /* rsrvd */ + name_len /* incl null */ ;
pSMB->TotalDataCount = 0; pSMB->TotalDataCount = 0;
pSMB->MaxParameterCount = cpu_to_le16(2); pSMB->MaxParameterCount = cpu_to_le16(2);
/* BB find exact max data count below from sess structure BB */ /* BB find exact max data count below from sess structure BB */
...@@ -1420,38 +1420,38 @@ CIFSSMBUnixQuerySymLink(const int xid, struct cifsTconInfo *tcon, ...@@ -1420,38 +1420,38 @@ CIFSSMBUnixQuerySymLink(const int xid, struct cifsTconInfo *tcon,
pSMB->SetupCount = 1; pSMB->SetupCount = 1;
pSMB->Reserved3 = 0; pSMB->Reserved3 = 0;
pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_PATH_INFORMATION); pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_PATH_INFORMATION);
pSMB->ByteCount = pSMB->TotalParameterCount + 1 /* pad */ ; byte_count = params + 1 /* pad */ ;
pSMB->TotalParameterCount = cpu_to_le16(pSMB->TotalParameterCount); pSMB->TotalParameterCount = cpu_to_le16(params);
pSMB->ParameterCount = pSMB->TotalParameterCount; pSMB->ParameterCount = pSMB->TotalParameterCount;
pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_UNIX_LINK); pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_UNIX_LINK);
pSMB->Reserved4 = 0; pSMB->Reserved4 = 0;
pSMB->hdr.smb_buf_length += pSMB->ByteCount; pSMB->hdr.smb_buf_length += byte_count;
pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); pSMB->ByteCount = cpu_to_le16(byte_count);
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
if (rc) { if (rc) {
cFYI(1, ("Send error in QuerySymLinkInfo = %d", rc)); cFYI(1, ("Send error in QuerySymLinkInfo = %d", rc));
} else { /* decode response */ } else { /* decode response */
pSMBr->DataOffset = le16_to_cpu(pSMBr->DataOffset); __u16 data_offset = le16_to_cpu(pSMBr->DataOffset);
pSMBr->DataCount = le16_to_cpu(pSMBr->DataCount); __u16 count = le16_to_cpu(pSMBr->DataCount);
if ((pSMBr->ByteCount < 2) || (pSMBr->DataOffset > 512)) if ((pSMBr->ByteCount < 2) || (data_offset > 512))
/* BB also check enough total bytes returned */ /* BB also check enough total bytes returned */
rc = -EIO; /* bad smb */ rc = -EIO; /* bad smb */
else { else {
if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) { if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) {
name_len = UniStrnlen((wchar_t *) ((char *) name_len = UniStrnlen((wchar_t *) ((char *)
&pSMBr->hdr.Protocol +pSMBr->DataOffset), &pSMBr->hdr.Protocol +data_offset),
min_t(const int, buflen,pSMBr->DataCount) / 2); min_t(const int, buflen,count) / 2);
cifs_strfromUCS_le(symlinkinfo, cifs_strfromUCS_le(symlinkinfo,
(wchar_t *) ((char *)&pSMBr->hdr.Protocol + (wchar_t *) ((char *)&pSMBr->hdr.Protocol +
pSMBr->DataOffset), data_offset),
name_len, nls_codepage); name_len, nls_codepage);
} else { } else {
strncpy(symlinkinfo, strncpy(symlinkinfo,
(char *) &pSMBr->hdr.Protocol + (char *) &pSMBr->hdr.Protocol +
pSMBr->DataOffset, data_offset,
min_t(const int, buflen, pSMBr->DataCount)); min_t(const int, buflen, count));
} }
symlinkinfo[buflen] = 0; symlinkinfo[buflen] = 0;
/* just in case so calling code does not go off the end of buffer */ /* just in case so calling code does not go off the end of buffer */
...@@ -1562,6 +1562,7 @@ CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, ...@@ -1562,6 +1562,7 @@ CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
int rc = 0; int rc = 0;
int bytes_returned; int bytes_returned;
int name_len; int name_len;
__u16 params, byte_count;
cFYI(1, ("In QPathInfo path %s", searchName)); cFYI(1, ("In QPathInfo path %s", searchName));
QPathInfoRetry: QPathInfoRetry:
...@@ -1583,8 +1584,7 @@ CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, ...@@ -1583,8 +1584,7 @@ CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
strncpy(pSMB->FileName, searchName, name_len); strncpy(pSMB->FileName, searchName, name_len);
} }
pSMB->TotalParameterCount = 2 /* level */ + 4 /* reserved */ + params = 2 /* level */ + 4 /* reserved */ + name_len /* includes NUL */ ;
name_len /* includes null */ ;
pSMB->TotalDataCount = 0; pSMB->TotalDataCount = 0;
pSMB->MaxParameterCount = cpu_to_le16(2); pSMB->MaxParameterCount = cpu_to_le16(2);
pSMB->MaxDataCount = cpu_to_le16(4000); /* BB find exact max SMB PDU from sess structure BB */ pSMB->MaxDataCount = cpu_to_le16(4000); /* BB find exact max SMB PDU from sess structure BB */
...@@ -1600,29 +1600,29 @@ CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, ...@@ -1600,29 +1600,29 @@ CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
pSMB->SetupCount = 1; pSMB->SetupCount = 1;
pSMB->Reserved3 = 0; pSMB->Reserved3 = 0;
pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_PATH_INFORMATION); pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_PATH_INFORMATION);
pSMB->ByteCount = pSMB->TotalParameterCount + 1 /* pad */ ; byte_count = params + 1 /* pad */ ;
pSMB->TotalParameterCount = cpu_to_le16(pSMB->TotalParameterCount); pSMB->TotalParameterCount = cpu_to_le16(params);
pSMB->ParameterCount = pSMB->TotalParameterCount; pSMB->ParameterCount = pSMB->TotalParameterCount;
pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO); pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO);
pSMB->Reserved4 = 0; pSMB->Reserved4 = 0;
pSMB->hdr.smb_buf_length += pSMB->ByteCount; pSMB->hdr.smb_buf_length += byte_count;
pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); pSMB->ByteCount = cpu_to_le16(byte_count);
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
if (rc) { if (rc) {
cFYI(1, ("Send error in QPathInfo = %d", rc)); cFYI(1, ("Send error in QPathInfo = %d", rc));
} else { /* decode response */ } else { /* decode response */
pSMBr->DataOffset = le16_to_cpu(pSMBr->DataOffset); __u16 data_offset = le16_to_cpu(pSMBr->DataOffset);
/* BB also check enough total bytes returned */ /* BB also check enough total bytes returned */
/* BB we need to improve the validity checking /* BB we need to improve the validity checking
of these trans2 responses */ of these trans2 responses */
if ((pSMBr->ByteCount < 40) || (pSMBr->DataOffset > 512)) if ((pSMBr->ByteCount < 40) || (data_offset > 512))
rc = -EIO; /* bad smb */ rc = -EIO; /* bad smb */
else if (pFindData){ else if (pFindData){
memcpy((char *) pFindData, memcpy((char *) pFindData,
(char *) &pSMBr->hdr.Protocol + (char *) &pSMBr->hdr.Protocol +
pSMBr->DataOffset, sizeof (FILE_ALL_INFO)); data_offset, sizeof (FILE_ALL_INFO));
} else } else
rc = -ENOMEM; rc = -ENOMEM;
} }
...@@ -1646,6 +1646,7 @@ CIFSSMBUnixQPathInfo(const int xid, struct cifsTconInfo *tcon, ...@@ -1646,6 +1646,7 @@ CIFSSMBUnixQPathInfo(const int xid, struct cifsTconInfo *tcon,
int rc = 0; int rc = 0;
int bytes_returned = 0; int bytes_returned = 0;
int name_len; int name_len;
__u16 params, byte_count;
cFYI(1, ("In QPathInfo (Unix) the path %s", searchName)); cFYI(1, ("In QPathInfo (Unix) the path %s", searchName));
UnixQPathInfoRetry: UnixQPathInfoRetry:
...@@ -1667,8 +1668,7 @@ CIFSSMBUnixQPathInfo(const int xid, struct cifsTconInfo *tcon, ...@@ -1667,8 +1668,7 @@ CIFSSMBUnixQPathInfo(const int xid, struct cifsTconInfo *tcon,
strncpy(pSMB->FileName, searchName, name_len); strncpy(pSMB->FileName, searchName, name_len);
} }
pSMB->TotalParameterCount = 2 /* level */ + 4 /* reserved */ + params = 2 /* level */ + 4 /* reserved */ + name_len /* includes NUL */ ;
name_len /* includes null */ ;
pSMB->TotalDataCount = 0; pSMB->TotalDataCount = 0;
pSMB->MaxParameterCount = cpu_to_le16(2); pSMB->MaxParameterCount = cpu_to_le16(2);
/* BB find exact max SMB PDU from sess structure BB */ /* BB find exact max SMB PDU from sess structure BB */
...@@ -1685,31 +1685,31 @@ CIFSSMBUnixQPathInfo(const int xid, struct cifsTconInfo *tcon, ...@@ -1685,31 +1685,31 @@ CIFSSMBUnixQPathInfo(const int xid, struct cifsTconInfo *tcon,
pSMB->SetupCount = 1; pSMB->SetupCount = 1;
pSMB->Reserved3 = 0; pSMB->Reserved3 = 0;
pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_PATH_INFORMATION); pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_PATH_INFORMATION);
pSMB->ByteCount = pSMB->TotalParameterCount + 1 /* pad */ ; byte_count = params + 1 /* pad */ ;
pSMB->TotalParameterCount = cpu_to_le16(pSMB->TotalParameterCount); pSMB->TotalParameterCount = cpu_to_le16(params);
pSMB->ParameterCount = pSMB->TotalParameterCount; pSMB->ParameterCount = pSMB->TotalParameterCount;
pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_UNIX_BASIC); pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_UNIX_BASIC);
pSMB->Reserved4 = 0; pSMB->Reserved4 = 0;
pSMB->hdr.smb_buf_length += pSMB->ByteCount; pSMB->hdr.smb_buf_length += byte_count;
pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); pSMB->ByteCount = cpu_to_le16(byte_count);
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
if (rc) { if (rc) {
cFYI(1, ("Send error in QPathInfo = %d", rc)); cFYI(1, ("Send error in QPathInfo = %d", rc));
} else { /* decode response */ } else { /* decode response */
pSMBr->DataOffset = le16_to_cpu(pSMBr->DataOffset); __u16 data_offset = le16_to_cpu(pSMBr->DataOffset);
/* BB also check if enough total bytes returned */ /* BB also check if enough total bytes returned */
if ((pSMBr->ByteCount < sizeof(FILE_UNIX_BASIC_INFO)) || if ((pSMBr->ByteCount < sizeof(FILE_UNIX_BASIC_INFO)) ||
(pSMBr->DataOffset > 512) || (data_offset > 512) ||
(pSMBr->DataOffset < sizeof(struct smb_hdr))) { (data_offset < sizeof(struct smb_hdr))) {
cFYI(1,("UnixQPathinfo invalid data offset %d bytes returned %d", cFYI(1,("UnixQPathinfo invalid data offset %d bytes returned %d",
(int)pSMBr->DataOffset,bytes_returned)); (int)data_offset,bytes_returned));
rc = -EIO; /* bad smb */ rc = -EIO; /* bad smb */
} else { } else {
memcpy((char *) pFindData, memcpy((char *) pFindData,
(char *) &pSMBr->hdr.Protocol + (char *) &pSMBr->hdr.Protocol +
pSMBr->DataOffset, data_offset,
sizeof (FILE_UNIX_BASIC_INFO)); sizeof (FILE_UNIX_BASIC_INFO));
} }
} }
...@@ -3024,6 +3024,7 @@ CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon, ...@@ -3024,6 +3024,7 @@ CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon,
int name_len; int name_len;
struct fea * temp_fea; struct fea * temp_fea;
char * temp_ptr; char * temp_ptr;
__u16 params, byte_count;
cFYI(1, ("In Query All EAs path %s", searchName)); cFYI(1, ("In Query All EAs path %s", searchName));
QAllEAsRetry: QAllEAsRetry:
...@@ -3045,8 +3046,7 @@ CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon, ...@@ -3045,8 +3046,7 @@ CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon,
strncpy(pSMB->FileName, searchName, name_len); strncpy(pSMB->FileName, searchName, name_len);
} }
pSMB->TotalParameterCount = 2 /* level */ + 4 /* reserved */ + params = 2 /* level */ + 4 /* reserved */ + name_len /* includes NUL */ ;
name_len /* includes null */ ;
pSMB->TotalDataCount = 0; pSMB->TotalDataCount = 0;
pSMB->MaxParameterCount = cpu_to_le16(2); pSMB->MaxParameterCount = cpu_to_le16(2);
pSMB->MaxDataCount = cpu_to_le16(4000); /* BB find exact max SMB PDU from sess structure BB */ pSMB->MaxDataCount = cpu_to_le16(4000); /* BB find exact max SMB PDU from sess structure BB */
...@@ -3062,29 +3062,29 @@ CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon, ...@@ -3062,29 +3062,29 @@ CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon,
pSMB->SetupCount = 1; pSMB->SetupCount = 1;
pSMB->Reserved3 = 0; pSMB->Reserved3 = 0;
pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_PATH_INFORMATION); pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_PATH_INFORMATION);
pSMB->ByteCount = pSMB->TotalParameterCount + 1 /* pad */ ; byte_count = params + 1 /* pad */ ;
pSMB->TotalParameterCount = cpu_to_le16(pSMB->TotalParameterCount); pSMB->TotalParameterCount = cpu_to_le16(params);
pSMB->ParameterCount = pSMB->TotalParameterCount; pSMB->ParameterCount = pSMB->TotalParameterCount;
pSMB->InformationLevel = cpu_to_le16(SMB_INFO_QUERY_ALL_EAS); pSMB->InformationLevel = cpu_to_le16(SMB_INFO_QUERY_ALL_EAS);
pSMB->Reserved4 = 0; pSMB->Reserved4 = 0;
pSMB->hdr.smb_buf_length += pSMB->ByteCount; pSMB->hdr.smb_buf_length += byte_count;
pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); pSMB->ByteCount = cpu_to_le16(byte_count);
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
if (rc) { if (rc) {
cFYI(1, ("Send error in QueryAllEAs = %d", rc)); cFYI(1, ("Send error in QueryAllEAs = %d", rc));
} else { /* decode response */ } else { /* decode response */
pSMBr->DataOffset = le16_to_cpu(pSMBr->DataOffset); __u16 data_offset = le16_to_cpu(pSMBr->DataOffset);
/* BB also check enough total bytes returned */ /* BB also check enough total bytes returned */
/* BB we need to improve the validity checking /* BB we need to improve the validity checking
of these trans2 responses */ of these trans2 responses */
if ((pSMBr->ByteCount < 4) || (pSMBr->DataOffset > 512)) if ((pSMBr->ByteCount < 4) || (data_offset > 512))
rc = -EIO; /* bad smb */ rc = -EIO; /* bad smb */
/* else if (pFindData){ /* else if (pFindData){
memcpy((char *) pFindData, memcpy((char *) pFindData,
(char *) &pSMBr->hdr.Protocol + (char *) &pSMBr->hdr.Protocol +
pSMBr->DataOffset, kl); data_offset, kl);
}*/ else { }*/ else {
/* check that length of list is not more than bcc */ /* check that length of list is not more than bcc */
/* check that each entry does not go beyond length /* check that each entry does not go beyond length
...@@ -3094,10 +3094,10 @@ CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon, ...@@ -3094,10 +3094,10 @@ CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon,
struct fealist * ea_response_data; struct fealist * ea_response_data;
rc = 0; rc = 0;
/* validate_trans2_offsets() */ /* validate_trans2_offsets() */
/* BB to check if(start of smb + pSMBr->DataOffset > &bcc+ bcc)*/ /* BB to check if(start of smb + data_offset > &bcc+ bcc)*/
ea_response_data = (struct fealist *) ea_response_data = (struct fealist *)
(((char *) &pSMBr->hdr.Protocol) + (((char *) &pSMBr->hdr.Protocol) +
pSMBr->DataOffset); data_offset);
ea_response_data->list_len = ea_response_data->list_len =
cpu_to_le32(ea_response_data->list_len); cpu_to_le32(ea_response_data->list_len);
cFYI(1,("ea length %d",ea_response_data->list_len)); cFYI(1,("ea length %d",ea_response_data->list_len));
...@@ -3167,6 +3167,7 @@ ssize_t CIFSSMBQueryEA(const int xid,struct cifsTconInfo * tcon, ...@@ -3167,6 +3167,7 @@ ssize_t CIFSSMBQueryEA(const int xid,struct cifsTconInfo * tcon,
int name_len; int name_len;
struct fea * temp_fea; struct fea * temp_fea;
char * temp_ptr; char * temp_ptr;
__u16 params, byte_count;
cFYI(1, ("In Query EA path %s", searchName)); cFYI(1, ("In Query EA path %s", searchName));
QEARetry: QEARetry:
...@@ -3188,8 +3189,7 @@ ssize_t CIFSSMBQueryEA(const int xid,struct cifsTconInfo * tcon, ...@@ -3188,8 +3189,7 @@ ssize_t CIFSSMBQueryEA(const int xid,struct cifsTconInfo * tcon,
strncpy(pSMB->FileName, searchName, name_len); strncpy(pSMB->FileName, searchName, name_len);
} }
pSMB->TotalParameterCount = 2 /* level */ + 4 /* reserved */ + params = 2 /* level */ + 4 /* reserved */ + name_len /* includes NUL */ ;
name_len /* includes null */ ;
pSMB->TotalDataCount = 0; pSMB->TotalDataCount = 0;
pSMB->MaxParameterCount = cpu_to_le16(2); pSMB->MaxParameterCount = cpu_to_le16(2);
pSMB->MaxDataCount = cpu_to_le16(4000); /* BB find exact max SMB PDU from sess structure BB */ pSMB->MaxDataCount = cpu_to_le16(4000); /* BB find exact max SMB PDU from sess structure BB */
...@@ -3205,29 +3205,29 @@ ssize_t CIFSSMBQueryEA(const int xid,struct cifsTconInfo * tcon, ...@@ -3205,29 +3205,29 @@ ssize_t CIFSSMBQueryEA(const int xid,struct cifsTconInfo * tcon,
pSMB->SetupCount = 1; pSMB->SetupCount = 1;
pSMB->Reserved3 = 0; pSMB->Reserved3 = 0;
pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_PATH_INFORMATION); pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_PATH_INFORMATION);
pSMB->ByteCount = pSMB->TotalParameterCount + 1 /* pad */ ; byte_count = params + 1 /* pad */ ;
pSMB->TotalParameterCount = cpu_to_le16(pSMB->TotalParameterCount); pSMB->TotalParameterCount = cpu_to_le16(params);
pSMB->ParameterCount = pSMB->TotalParameterCount; pSMB->ParameterCount = pSMB->TotalParameterCount;
pSMB->InformationLevel = cpu_to_le16(SMB_INFO_QUERY_ALL_EAS); pSMB->InformationLevel = cpu_to_le16(SMB_INFO_QUERY_ALL_EAS);
pSMB->Reserved4 = 0; pSMB->Reserved4 = 0;
pSMB->hdr.smb_buf_length += pSMB->ByteCount; pSMB->hdr.smb_buf_length += byte_count;
pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); pSMB->ByteCount = cpu_to_le16(byte_count);
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
if (rc) { if (rc) {
cFYI(1, ("Send error in Query EA = %d", rc)); cFYI(1, ("Send error in Query EA = %d", rc));
} else { /* decode response */ } else { /* decode response */
pSMBr->DataOffset = le16_to_cpu(pSMBr->DataOffset); __u16 data_offset = le16_to_cpu(pSMBr->DataOffset);
/* BB also check enough total bytes returned */ /* BB also check enough total bytes returned */
/* BB we need to improve the validity checking /* BB we need to improve the validity checking
of these trans2 responses */ of these trans2 responses */
if ((pSMBr->ByteCount < 4) || (pSMBr->DataOffset > 512)) if ((pSMBr->ByteCount < 4) || (data_offset > 512))
rc = -EIO; /* bad smb */ rc = -EIO; /* bad smb */
/* else if (pFindData){ /* else if (pFindData){
memcpy((char *) pFindData, memcpy((char *) pFindData,
(char *) &pSMBr->hdr.Protocol + (char *) &pSMBr->hdr.Protocol +
pSMBr->DataOffset, kl); data_offset, kl);
}*/ else { }*/ else {
/* check that length of list is not more than bcc */ /* check that length of list is not more than bcc */
/* check that each entry does not go beyond length /* check that each entry does not go beyond length
...@@ -3237,10 +3237,10 @@ ssize_t CIFSSMBQueryEA(const int xid,struct cifsTconInfo * tcon, ...@@ -3237,10 +3237,10 @@ ssize_t CIFSSMBQueryEA(const int xid,struct cifsTconInfo * tcon,
struct fealist * ea_response_data; struct fealist * ea_response_data;
rc = -ENOENT; rc = -ENOENT;
/* validate_trans2_offsets() */ /* validate_trans2_offsets() */
/* BB to check if(start of smb + pSMBr->DataOffset > &bcc+ bcc)*/ /* BB to check if(start of smb + data_offset > &bcc+ bcc)*/
ea_response_data = (struct fealist *) ea_response_data = (struct fealist *)
(((char *) &pSMBr->hdr.Protocol) + (((char *) &pSMBr->hdr.Protocol) +
pSMBr->DataOffset); data_offset);
ea_response_data->list_len = ea_response_data->list_len =
cpu_to_le32(ea_response_data->list_len); cpu_to_le32(ea_response_data->list_len);
cFYI(1,("ea length %d",ea_response_data->list_len)); cFYI(1,("ea length %d",ea_response_data->list_len));
......
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