diff options
author | Eric Paris <eparis@redhat.com> | 2012-10-10 15:25:24 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-10-12 00:32:02 -0400 |
commit | 29e9a3467c1367549568d7d411d5f30209ae181b (patch) | |
tree | 9da23e302f9dcff070f9187f2882ee76262be601 | |
parent | 563a0d1236c2c58d584ef122a5cdc9930e5860b3 (diff) |
audit: make audit_compare_dname_path use parent_len helper
Signed-off-by: Eric Paris <eparis@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | kernel/auditfilter.c | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c index ff4011c19b13..d705eb17661b 100644 --- a/kernel/auditfilter.c +++ b/kernel/auditfilter.c | |||
@@ -1332,32 +1332,19 @@ int parent_len(const char *path) | |||
1332 | * return of 0 indicates a match. */ | 1332 | * return of 0 indicates a match. */ |
1333 | int audit_compare_dname_path(const char *dname, const char *path) | 1333 | int audit_compare_dname_path(const char *dname, const char *path) |
1334 | { | 1334 | { |
1335 | int dlen, plen; | 1335 | int dlen, pathlen, parentlen; |
1336 | const char *p; | 1336 | const char *p; |
1337 | 1337 | ||
1338 | if (!dname || !path) | ||
1339 | return 1; | ||
1340 | |||
1341 | dlen = strlen(dname); | 1338 | dlen = strlen(dname); |
1342 | plen = strlen(path); | 1339 | pathlen = strlen(path); |
1343 | if (plen < dlen) | 1340 | if (pathlen < dlen) |
1344 | return 1; | 1341 | return 1; |
1345 | 1342 | ||
1346 | /* disregard trailing slashes */ | 1343 | parentlen = parent_len(path); |
1347 | p = path + plen - 1; | 1344 | if (pathlen - parentlen != dlen) |
1348 | while ((*p == '/') && (p > path)) | ||
1349 | p--; | ||
1350 | |||
1351 | /* find last path component */ | ||
1352 | p = p - dlen + 1; | ||
1353 | if (p < path) | ||
1354 | return 1; | 1345 | return 1; |
1355 | else if (p > path) { | 1346 | |
1356 | if (*--p != '/') | 1347 | p = path + parentlen; |
1357 | return 1; | ||
1358 | else | ||
1359 | p++; | ||
1360 | } | ||
1361 | 1348 | ||
1362 | return strncmp(p, dname, dlen); | 1349 | return strncmp(p, dname, dlen); |
1363 | } | 1350 | } |