Commit afe48c31 authored by Steve French's avatar Steve French

[CIFS] Fix final user of old string conversion code

Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent 34106027
...@@ -2564,7 +2564,6 @@ validate_ntransact(char *buf, char **ppparm, char **ppdata, ...@@ -2564,7 +2564,6 @@ validate_ntransact(char *buf, char **ppparm, char **ppdata,
*pparmlen = parm_count; *pparmlen = parm_count;
return 0; return 0;
} }
#endif /* CIFS_EXPERIMENTAL */
int int
CIFSSMBQueryReparseLinkInfo(const int xid, struct cifsTconInfo *tcon, CIFSSMBQueryReparseLinkInfo(const int xid, struct cifsTconInfo *tcon,
...@@ -2611,59 +2610,55 @@ CIFSSMBQueryReparseLinkInfo(const int xid, struct cifsTconInfo *tcon, ...@@ -2611,59 +2610,55 @@ CIFSSMBQueryReparseLinkInfo(const int xid, struct cifsTconInfo *tcon,
} else { /* decode response */ } else { /* decode response */
__u32 data_offset = le32_to_cpu(pSMBr->DataOffset); __u32 data_offset = le32_to_cpu(pSMBr->DataOffset);
__u32 data_count = le32_to_cpu(pSMBr->DataCount); __u32 data_count = le32_to_cpu(pSMBr->DataCount);
if ((pSMBr->ByteCount < 2) || (data_offset > 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 { goto qreparse_out;
if (data_count && (data_count < 2048)) { }
char *end_of_smb = 2 /* sizeof byte count */ + if (data_count && (data_count < 2048)) {
pSMBr->ByteCount + char *end_of_smb = 2 /* sizeof byte count */ +
(char *)&pSMBr->ByteCount; pSMBr->ByteCount + (char *)&pSMBr->ByteCount;
struct reparse_data *reparse_buf = struct reparse_data *reparse_buf =
(struct reparse_data *) (struct reparse_data *)
((char *)&pSMBr->hdr.Protocol ((char *)&pSMBr->hdr.Protocol
+ data_offset); + data_offset);
if ((char *)reparse_buf >= end_of_smb) { if ((char *)reparse_buf >= end_of_smb) {
rc = -EIO; rc = -EIO;
goto qreparse_out; goto qreparse_out;
} }
if ((reparse_buf->LinkNamesBuf + if ((reparse_buf->LinkNamesBuf +
reparse_buf->TargetNameOffset + reparse_buf->TargetNameOffset +
reparse_buf->TargetNameLen) > reparse_buf->TargetNameLen) > end_of_smb) {
end_of_smb) { cFYI(1, ("reparse buf beyond SMB"));
cFYI(1, ("reparse buf beyond SMB")); rc = -EIO;
rc = -EIO; goto qreparse_out;
goto qreparse_out; }
}
if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) { if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) {
name_len = UniStrnlen((wchar_t *) cifs_from_ucs2(symlinkinfo, (__le16 *)
(reparse_buf->LinkNamesBuf + (reparse_buf->LinkNamesBuf +
reparse_buf->TargetNameOffset), reparse_buf->TargetNameOffset),
min(buflen/2, buflen,
reparse_buf->TargetNameLen / 2)); reparse_buf->TargetNameLen,
cifs_strfromUCS_le(symlinkinfo, nls_codepage, 0);
(__le16 *) (reparse_buf->LinkNamesBuf + } else { /* ASCII names */
reparse_buf->TargetNameOffset), strncpy(symlinkinfo,
name_len, nls_codepage); reparse_buf->LinkNamesBuf +
} else { /* ASCII names */ reparse_buf->TargetNameOffset,
strncpy(symlinkinfo, min_t(const int, buflen,
reparse_buf->LinkNamesBuf + reparse_buf->TargetNameLen));
reparse_buf->TargetNameOffset,
min_t(const int, buflen,
reparse_buf->TargetNameLen));
}
} else {
rc = -EIO;
cFYI(1, ("Invalid return data count on "
"get reparse info ioctl"));
} }
symlinkinfo[buflen] = 0; /* just in case so the caller } else {
does not go off the end of the buffer */ rc = -EIO;
cFYI(1, ("readlink result - %s", symlinkinfo)); cFYI(1, ("Invalid return data count on "
"get reparse info ioctl"));
} }
symlinkinfo[buflen] = 0; /* just in case so the caller
does not go off the end of the buffer */
cFYI(1, ("readlink result - %s", symlinkinfo));
} }
qreparse_out: qreparse_out:
cifs_buf_release(pSMB); cifs_buf_release(pSMB);
...@@ -2672,6 +2667,7 @@ qreparse_out: ...@@ -2672,6 +2667,7 @@ qreparse_out:
return rc; return rc;
} }
#endif /* CIFS_EXPERIMENTAL */
#ifdef CONFIG_CIFS_POSIX #ifdef CONFIG_CIFS_POSIX
......
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