Skip to content

Commit 24cf729

Browse files
paliSteve French
authored andcommitted
cifs: Remove unicode parameter from parse_reparse_point() function
This parameter is always true, so remove it and also remove dead code which is never called (for all false code paths). Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 8b19dfb commit 24cf729

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

fs/smb/client/cifsproto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ char *extract_sharename(const char *unc);
656656
int parse_reparse_point(struct reparse_data_buffer *buf,
657657
u32 plen, struct cifs_sb_info *cifs_sb,
658658
const char *full_path,
659-
bool unicode, struct cifs_open_info_data *data);
659+
struct cifs_open_info_data *data);
660660
int __cifs_sfu_make_node(unsigned int xid, struct inode *inode,
661661
struct dentry *dentry, struct cifs_tcon *tcon,
662662
const char *full_path, umode_t mode, dev_t dev,

fs/smb/client/reparse.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ static int parse_reparse_posix(struct reparse_posix_data *buf,
536536
}
537537

538538
int smb2_parse_native_symlink(char **target, const char *buf, unsigned int len,
539-
bool unicode, bool relative,
539+
bool relative,
540540
const char *full_path,
541541
struct cifs_sb_info *cifs_sb)
542542
{
@@ -547,26 +547,24 @@ int smb2_parse_native_symlink(char **target, const char *buf, unsigned int len,
547547
int rc;
548548
int i;
549549

550-
/* Check that length it valid for unicode/non-unicode mode */
551-
if (!len || (unicode && (len % 2))) {
550+
/* Check that length it valid */
551+
if (!len || (len % 2)) {
552552
cifs_dbg(VFS, "srv returned malformed symlink buffer\n");
553553
rc = -EIO;
554554
goto out;
555555
}
556556

557557
/*
558-
* Check that buffer does not contain UTF-16 null codepoint in unicode
559-
* mode or null byte in non-unicode mode because Linux cannot process
560-
* symlink with null byte.
558+
* Check that buffer does not contain UTF-16 null codepoint
559+
* because Linux cannot process symlink with null byte.
561560
*/
562-
if ((unicode && UniStrnlen((wchar_t *)buf, len/2) != len/2) ||
563-
(!unicode && strnlen(buf, len) != len)) {
561+
if (UniStrnlen((wchar_t *)buf, len/2) != len/2) {
564562
cifs_dbg(VFS, "srv returned null byte in native symlink target location\n");
565563
rc = -EIO;
566564
goto out;
567565
}
568566

569-
smb_target = cifs_strndup_from_utf16(buf, len, unicode, cifs_sb->local_nls);
567+
smb_target = cifs_strndup_from_utf16(buf, len, true, cifs_sb->local_nls);
570568
if (!smb_target) {
571569
rc = -ENOMEM;
572570
goto out;
@@ -621,7 +619,7 @@ int smb2_parse_native_symlink(char **target, const char *buf, unsigned int len,
621619
}
622620

623621
static int parse_reparse_symlink(struct reparse_symlink_data_buffer *sym,
624-
u32 plen, bool unicode,
622+
u32 plen,
625623
struct cifs_sb_info *cifs_sb,
626624
const char *full_path,
627625
struct cifs_open_info_data *data)
@@ -641,7 +639,6 @@ static int parse_reparse_symlink(struct reparse_symlink_data_buffer *sym,
641639
return smb2_parse_native_symlink(&data->symlink_target,
642640
sym->PathBuffer + offs,
643641
len,
644-
unicode,
645642
le32_to_cpu(sym->Flags) & SYMLINK_FLAG_RELATIVE,
646643
full_path,
647644
cifs_sb);
@@ -696,7 +693,7 @@ static int parse_reparse_wsl_symlink(struct reparse_wsl_symlink_data_buffer *buf
696693
int parse_reparse_point(struct reparse_data_buffer *buf,
697694
u32 plen, struct cifs_sb_info *cifs_sb,
698695
const char *full_path,
699-
bool unicode, struct cifs_open_info_data *data)
696+
struct cifs_open_info_data *data)
700697
{
701698
struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
702699

@@ -710,7 +707,7 @@ int parse_reparse_point(struct reparse_data_buffer *buf,
710707
case IO_REPARSE_TAG_SYMLINK:
711708
return parse_reparse_symlink(
712709
(struct reparse_symlink_data_buffer *)buf,
713-
plen, unicode, cifs_sb, full_path, data);
710+
plen, cifs_sb, full_path, data);
714711
case IO_REPARSE_TAG_LX_SYMLINK:
715712
return parse_reparse_wsl_symlink(
716713
(struct reparse_wsl_symlink_data_buffer *)buf,
@@ -744,7 +741,7 @@ int smb2_parse_reparse_point(struct cifs_sb_info *cifs_sb,
744741

745742
buf = (struct reparse_data_buffer *)((u8 *)io +
746743
le32_to_cpu(io->OutputOffset));
747-
return parse_reparse_point(buf, plen, cifs_sb, full_path, true, data);
744+
return parse_reparse_point(buf, plen, cifs_sb, full_path, data);
748745
}
749746

750747
static bool wsl_to_fattr(struct cifs_open_info_data *data,

fs/smb/client/smb1ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ static int cifs_parse_reparse_point(struct cifs_sb_info *cifs_sb,
10101010

10111011
buf = (struct reparse_data_buffer *)((__u8 *)&io->hdr.Protocol +
10121012
le32_to_cpu(io->DataOffset));
1013-
return parse_reparse_point(buf, plen, cifs_sb, full_path, true, data);
1013+
return parse_reparse_point(buf, plen, cifs_sb, full_path, data);
10141014
}
10151015

10161016
static bool

fs/smb/client/smb2file.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ int smb2_parse_symlink_response(struct cifs_sb_info *cifs_sb, const struct kvec
8989
return smb2_parse_native_symlink(path,
9090
(char *)sym->PathBuffer + sub_offs,
9191
sub_len,
92-
true,
9392
le32_to_cpu(sym->Flags) & SYMLINK_FLAG_RELATIVE,
9493
full_path,
9594
cifs_sb);

fs/smb/client/smb2proto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ extern int smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
112112
const unsigned char *path, char *pbuf,
113113
unsigned int *pbytes_read);
114114
int smb2_parse_native_symlink(char **target, const char *buf, unsigned int len,
115-
bool unicode, bool relative,
115+
bool relative,
116116
const char *full_path,
117117
struct cifs_sb_info *cifs_sb);
118118
int smb2_parse_symlink_response(struct cifs_sb_info *cifs_sb,

0 commit comments

Comments
 (0)