aboutsummaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorDaniel Rosenberg <drosen@google.com>2017-03-08 17:20:02 -0800
committerMister Oyster <oysterized@gmail.com>2017-04-13 12:35:18 +0200
commit059c835f48bc24e6120a24c22fa07d333d21da12 (patch)
treeaa00283f67e8bb63f89a78ee7b270c517614fde9 /fs
parentdf1d216cd1cf586a3681e99f8614de9f6811d30c (diff)
ANDROID: sdcardfs: Switch to internal case insensitive compare
There were still a few places where we called into a case insensitive lookup that was not defined by sdcardfs. Moving them all to the same place will allow us to switch the implementation in the future. Additionally, the check in fixup_perms_recursive did not take into account the length of both strings, causing extraneous matches when the name we were looking for was a prefix of the child name. Signed-off-by: Daniel Rosenberg <drosen@google.com> Change-Id: I45ce768cd782cb4ea1ae183772781387c590ecc2
Diffstat (limited to 'fs')
-rwxr-xr-xfs/sdcardfs/dentry.c8
-rwxr-xr-xfs/sdcardfs/derived_perm.c2
-rwxr-xr-xfs/sdcardfs/packagelist.c6
-rwxr-xr-xfs/sdcardfs/sdcardfs.h7
4 files changed, 10 insertions, 13 deletions
diff --git a/fs/sdcardfs/dentry.c b/fs/sdcardfs/dentry.c
index f03f16d3e..4e9d2249e 100755
--- a/fs/sdcardfs/dentry.c
+++ b/fs/sdcardfs/dentry.c
@@ -82,11 +82,7 @@ static int sdcardfs_d_revalidate(struct dentry *dentry, unsigned int flags)
spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
}
- if (dentry->d_name.len != lower_dentry->d_name.len) {
- __d_drop(dentry);
- err = 0;
- } else if (strncasecmp(dentry->d_name.name, lower_dentry->d_name.name,
- dentry->d_name.len) != 0) {
+ if (!qstr_case_eq(&dentry->d_name, &lower_dentry->d_name)) {
__d_drop(dentry);
err = 0;
}
@@ -167,7 +163,7 @@ static int sdcardfs_cmp_ci(const struct dentry *parent,
}
*/
if (name->len == len) {
- if (strncasecmp(name->name, str, len) == 0)
+ if (str_n_case_eq(name->name, str, len))
return 0;
}
return 1;
diff --git a/fs/sdcardfs/derived_perm.c b/fs/sdcardfs/derived_perm.c
index ce2f9d34a..b704afb06 100755
--- a/fs/sdcardfs/derived_perm.c
+++ b/fs/sdcardfs/derived_perm.c
@@ -274,7 +274,7 @@ static void __fixup_perms_recursive(struct dentry *dentry, struct limit_search *
if (needs_fixup(info->perm)) {
list_for_each_entry(child, &dentry->d_subdirs, d_child) {
spin_lock_nested(&child->d_lock, depth + 1);
- if (!(limit->flags & BY_NAME) || !strncasecmp(child->d_name.name, limit->name, limit->length)) {
+ if (!(limit->flags & BY_NAME) || qstr_case_eq(&child->d_name, &limit->name)) {
if (child->d_inode) {
get_derived_permission(dentry, child);
fixup_tmp_permissions(child->d_inode);
diff --git a/fs/sdcardfs/packagelist.c b/fs/sdcardfs/packagelist.c
index 21eb2d317..490dd9702 100755
--- a/fs/sdcardfs/packagelist.c
+++ b/fs/sdcardfs/packagelist.c
@@ -251,8 +251,7 @@ static void fixup_all_perms_name(const struct qstr *key)
struct sdcardfs_sb_info *sbinfo;
struct limit_search limit = {
.flags = BY_NAME,
- .name = key->name,
- .length = key->len,
+ .name = QSTR_INIT(key->name, key->len),
};
list_for_each_entry(sbinfo, &sdcardfs_super_list, list) {
if (sbinfo_has_sdcard_magic(sbinfo))
@@ -265,8 +264,7 @@ static void fixup_all_perms_name_userid(const struct qstr *key, userid_t userid)
struct sdcardfs_sb_info *sbinfo;
struct limit_search limit = {
.flags = BY_NAME | BY_USERID,
- .name = key->name,
- .length = key->len,
+ .name = QSTR_INIT(key->name, key->len),
.userid = userid,
};
list_for_each_entry(sbinfo, &sdcardfs_super_list, list) {
diff --git a/fs/sdcardfs/sdcardfs.h b/fs/sdcardfs/sdcardfs.h
index e5667e5bf..ec0f442f9 100755
--- a/fs/sdcardfs/sdcardfs.h
+++ b/fs/sdcardfs/sdcardfs.h
@@ -471,8 +471,7 @@ extern void packagelist_exit(void);
#define BY_USERID (1 << 1)
struct limit_search {
unsigned int flags;
- const char *name;
- size_t length;
+ struct qstr name;
userid_t userid;
};
@@ -614,6 +613,10 @@ static inline bool str_case_eq(const char *s1, const char *s2)
return !strcasecmp(s1, s2);
}
+static inline bool str_n_case_eq(const char *s1, const char *s2, size_t len) {
+ return !strncasecmp(s1, s2, len);
+}
+
static inline bool qstr_case_eq(const struct qstr *q1, const struct qstr *q2)
{
return q1->len == q2->len && str_case_eq(q1->name, q2->name);