aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/cifssmb.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2011-07-26 18:23:47 -0400
committerSteve French <sfrench@us.ibm.com>2011-07-31 17:21:09 -0400
commit91d065c47317cd5f6577fa077cca3383c8d9243d (patch)
treeb233806b287b9b97f9c085f2e0dc280d031961ed /fs/cifs/cifssmb.c
parent998d6fcb24d25b7889ec39118cf98d5089ac4c11 (diff)
cifs: fix name parsing in CIFSSMBQAllEAs
The code that matches EA names in CIFSSMBQAllEAs is incorrect. It uses strncmp to do the comparison with the length limited to the name_len sent in the response. Problem: Suppose we're looking for an attribute named "foobar" and have an attribute before it in the EA list named "foo". The comparison will succeed since we're only looking at the first 3 characters. Fix this by also comparing the length of the provided ea_name with the name_len in the response. If they're not equal then it shouldn't match. Reported-by: Jian Li <jiali@redhat.com> Signed-off-by: Jeff Layton <jlayton@redhat.com> Reviewed-by: Pavel Shilovsky <piastryyy@gmail.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/cifssmb.c')
-rw-r--r--fs/cifs/cifssmb.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 1a9fe7f816d1..0580da1cf34c 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -5720,6 +5720,7 @@ CIFSSMBQAllEAs(const int xid, struct cifs_tcon *tcon,
5720 char *temp_ptr; 5720 char *temp_ptr;
5721 char *end_of_smb; 5721 char *end_of_smb;
5722 __u16 params, byte_count, data_offset; 5722 __u16 params, byte_count, data_offset;
5723 unsigned int ea_name_len;
5723 5724
5724 cFYI(1, "In Query All EAs path %s", searchName); 5725 cFYI(1, "In Query All EAs path %s", searchName);
5725QAllEAsRetry: 5726QAllEAsRetry:
@@ -5814,6 +5815,10 @@ QAllEAsRetry:
5814 list_len -= 4; 5815 list_len -= 4;
5815 temp_fea = ea_response_data->list; 5816 temp_fea = ea_response_data->list;
5816 temp_ptr = (char *)temp_fea; 5817 temp_ptr = (char *)temp_fea;
5818
5819 if (ea_name)
5820 ea_name_len = strlen(ea_name);
5821
5817 while (list_len > 0) { 5822 while (list_len > 0) {
5818 unsigned int name_len; 5823 unsigned int name_len;
5819 __u16 value_len; 5824 __u16 value_len;
@@ -5837,7 +5842,8 @@ QAllEAsRetry:
5837 } 5842 }
5838 5843
5839 if (ea_name) { 5844 if (ea_name) {
5840 if (strncmp(ea_name, temp_ptr, name_len) == 0) { 5845 if (ea_name_len == name_len &&
5846 strncmp(ea_name, temp_ptr, name_len) == 0) {
5841 temp_ptr += name_len + 1; 5847 temp_ptr += name_len + 1;
5842 rc = value_len; 5848 rc = value_len;
5843 if (buf_size == 0) 5849 if (buf_size == 0)