diff options
author | Jeff Layton <jlayton@redhat.com> | 2009-04-30 20:45:45 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2009-04-30 20:49:23 -0400 |
commit | 18295796a30cada84e933d805072dc2248d54f98 (patch) | |
tree | 33bb2720165640fefc2987878a507d6797994891 /fs/cifs/readdir.c | |
parent | 9e39b0ae8af46c83b85dae7ff5251911a80fce5a (diff) |
cifs: fix length handling in cifs_get_name_from_search_buf
The earlier patch to move this code to use the new unicode helpers
assumed that the filename strings would be null terminated. That's not
always the case.
Instead of passing "max_len" to the string converter, pass "min(len,
max_len)", which makes it do the right thing while still keeping the
parser confined to the response. Also fix up the prototypes of this
function and the callers so that max_len is unsigned (like len is).
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/readdir.c')
-rw-r--r-- | fs/cifs/readdir.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index e1351fe18a15..5bc9ab7586bc 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c | |||
@@ -829,7 +829,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon, | |||
829 | /* inode num, inode type and filename returned */ | 829 | /* inode num, inode type and filename returned */ |
830 | static int cifs_get_name_from_search_buf(struct qstr *pqst, | 830 | static int cifs_get_name_from_search_buf(struct qstr *pqst, |
831 | char *current_entry, __u16 level, unsigned int unicode, | 831 | char *current_entry, __u16 level, unsigned int unicode, |
832 | struct cifs_sb_info *cifs_sb, int max_len, __u64 *pinum) | 832 | struct cifs_sb_info *cifs_sb, unsigned int max_len, __u64 *pinum) |
833 | { | 833 | { |
834 | int rc = 0; | 834 | int rc = 0; |
835 | unsigned int len = 0; | 835 | unsigned int len = 0; |
@@ -890,7 +890,8 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst, | |||
890 | if (unicode) { | 890 | if (unicode) { |
891 | pqst->len = cifs_from_ucs2((char *) pqst->name, | 891 | pqst->len = cifs_from_ucs2((char *) pqst->name, |
892 | (__le16 *) filename, | 892 | (__le16 *) filename, |
893 | UNICODE_NAME_MAX, max_len, nlt, | 893 | UNICODE_NAME_MAX, |
894 | min(len, max_len), nlt, | ||
894 | cifs_sb->mnt_cifs_flags & | 895 | cifs_sb->mnt_cifs_flags & |
895 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 896 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
896 | } else { | 897 | } else { |
@@ -902,8 +903,8 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst, | |||
902 | return rc; | 903 | return rc; |
903 | } | 904 | } |
904 | 905 | ||
905 | static int cifs_filldir(char *pfindEntry, struct file *file, | 906 | static int cifs_filldir(char *pfindEntry, struct file *file, filldir_t filldir, |
906 | filldir_t filldir, void *direntry, char *scratch_buf, int max_len) | 907 | void *direntry, char *scratch_buf, unsigned int max_len) |
907 | { | 908 | { |
908 | int rc = 0; | 909 | int rc = 0; |
909 | struct qstr qstring; | 910 | struct qstr qstring; |
@@ -1000,7 +1001,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir) | |||
1000 | int num_to_fill = 0; | 1001 | int num_to_fill = 0; |
1001 | char *tmp_buf = NULL; | 1002 | char *tmp_buf = NULL; |
1002 | char *end_of_smb; | 1003 | char *end_of_smb; |
1003 | int max_len; | 1004 | unsigned int max_len; |
1004 | 1005 | ||
1005 | xid = GetXid(); | 1006 | xid = GetXid(); |
1006 | 1007 | ||