Skip to content

Commit 5e0c969

Browse files
Ronnie Sahlbergsmfrench
authored andcommitted
cifs: convert the path to utf16 in smb2_query_info_compound
and not in the callers. Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 70ef385 commit 5e0c969

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

fs/cifs/smb2ops.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,17 +1192,12 @@ smb2_query_eas(const unsigned int xid, struct cifs_tcon *tcon,
11921192
struct cifs_sb_info *cifs_sb)
11931193
{
11941194
int rc;
1195-
__le16 *utf16_path;
11961195
struct kvec rsp_iov = {NULL, 0};
11971196
int buftype = CIFS_NO_BUFFER;
11981197
struct smb2_query_info_rsp *rsp;
11991198
struct smb2_file_full_ea_info *info = NULL;
12001199

1201-
utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
1202-
if (!utf16_path)
1203-
return -ENOMEM;
1204-
1205-
rc = smb2_query_info_compound(xid, tcon, utf16_path,
1200+
rc = smb2_query_info_compound(xid, tcon, path,
12061201
FILE_READ_EA,
12071202
FILE_FULL_EA_INFORMATION,
12081203
SMB2_O_INFO_FILE,
@@ -1235,7 +1230,6 @@ smb2_query_eas(const unsigned int xid, struct cifs_tcon *tcon,
12351230
le32_to_cpu(rsp->OutputBufferLength), ea_name);
12361231

12371232
qeas_exit:
1238-
kfree(utf16_path);
12391233
free_rsp_buf(buftype, rsp_iov.iov_base);
12401234
return rc;
12411235
}
@@ -1295,7 +1289,7 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
12951289
* the new EA. If not we should not add it since we
12961290
* would not be able to even read the EAs back.
12971291
*/
1298-
rc = smb2_query_info_compound(xid, tcon, utf16_path,
1292+
rc = smb2_query_info_compound(xid, tcon, path,
12991293
FILE_READ_EA,
13001294
FILE_FULL_EA_INFORMATION,
13011295
SMB2_O_INFO_FILE,
@@ -2646,7 +2640,7 @@ smb2_set_next_command(struct cifs_tcon *tcon, struct smb_rqst *rqst)
26462640
*/
26472641
int
26482642
smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon,
2649-
__le16 *utf16_path, u32 desired_access,
2643+
const char *path, u32 desired_access,
26502644
u32 class, u32 type, u32 output_len,
26512645
struct kvec *rsp, int *buftype,
26522646
struct cifs_sb_info *cifs_sb)
@@ -2664,6 +2658,13 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon,
26642658
struct cifs_open_parms oparms;
26652659
struct cifs_fid fid;
26662660
int rc;
2661+
__le16 *utf16_path;
2662+
2663+
if (!path)
2664+
path = "";
2665+
utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
2666+
if (!utf16_path)
2667+
return -ENOMEM;
26672668

26682669
if (smb3_encryption_required(tcon))
26692670
flags |= CIFS_TRANSFORM_REQ;
@@ -2729,6 +2730,7 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon,
27292730
*buftype = resp_buftype[1];
27302731

27312732
qic_exit:
2733+
kfree(utf16_path);
27322734
SMB2_open_free(&rqst[0]);
27332735
SMB2_query_info_free(&rqst[1]);
27342736
SMB2_close_free(&rqst[2]);
@@ -2743,13 +2745,12 @@ smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
27432745
{
27442746
struct smb2_query_info_rsp *rsp;
27452747
struct smb2_fs_full_size_info *info = NULL;
2746-
__le16 utf16_path = 0; /* Null - open root of share */
27472748
struct kvec rsp_iov = {NULL, 0};
27482749
int buftype = CIFS_NO_BUFFER;
27492750
int rc;
27502751

27512752

2752-
rc = smb2_query_info_compound(xid, tcon, &utf16_path,
2753+
rc = smb2_query_info_compound(xid, tcon, "",
27532754
FILE_READ_ATTRIBUTES,
27542755
FS_FULL_SIZE_INFORMATION,
27552756
SMB2_O_INFO_FILESYSTEM,

fs/cifs/smb2proto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ extern int smb311_update_preauth_hash(struct cifs_ses *ses,
283283
struct kvec *iov, int nvec);
284284
extern int smb2_query_info_compound(const unsigned int xid,
285285
struct cifs_tcon *tcon,
286-
__le16 *utf16_path, u32 desired_access,
286+
const char *path, u32 desired_access,
287287
u32 class, u32 type, u32 output_len,
288288
struct kvec *rsp, int *buftype,
289289
struct cifs_sb_info *cifs_sb);

0 commit comments

Comments
 (0)