]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
audit: make audit_compare_dname_path use parent_len helper
authorEric Paris <eparis@redhat.com>
Wed, 10 Oct 2012 19:25:24 +0000 (15:25 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 12 Oct 2012 04:32:02 +0000 (00:32 -0400)
Signed-off-by: Eric Paris <eparis@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
kernel/auditfilter.c

index ff4011c19b13843dd443f28ab05b5d497c63445d..d705eb17661b41bf57de82976d9db06f488c1cf4 100644 (file)
@@ -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);
 }