summary refs log tree commit diff
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2012-10-10 15:25:24 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-10-12 00:32:02 -0400
commit29e9a3467c1367549568d7d411d5f30209ae181b (patch)
tree9da23e302f9dcff070f9187f2882ee76262be601
parent563a0d1236c2c58d584ef122a5cdc9930e5860b3 (diff)
downloadlinux-29e9a3467c1367549568d7d411d5f30209ae181b.tar.gz
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.c27
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)
  * return of 0 indicates a match. */
 int audit_compare_dname_path(const char *dname, const char *path)
 {
-	int dlen, plen;
+	int dlen, pathlen, parentlen;
 	const char *p;
 
-	if (!dname || !path)
-		return 1;
-
 	dlen = strlen(dname);
-	plen = strlen(path);
-	if (plen < dlen)
+	pathlen = strlen(path);
+	if (pathlen < dlen)
 		return 1;
 
-	/* disregard trailing slashes */
-	p = path + plen - 1;
-	while ((*p == '/') && (p > path))
-		p--;
-
-	/* find last path component */
-	p = p - dlen + 1;
-	if (p < path)
+	parentlen = parent_len(path);
+	if (pathlen - parentlen != dlen)
 		return 1;
-	else if (p > path) {
-		if (*--p != '/')
-			return 1;
-		else
-			p++;
-	}
+
+	p = path + parentlen;
 
 	return strncmp(p, dname, dlen);
 }