提交 29e9a346 编写于 作者: E Eric Paris 提交者: Al Viro

audit: make audit_compare_dname_path use parent_len helper

Signed-off-by: NEric Paris <eparis@redhat.com>
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 563a0d12
......@@ -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)
return 1;
else if (p > path) {
if (*--p != '/')
parentlen = parent_len(path);
if (pathlen - parentlen != dlen)
return 1;
else
p++;
}
p = path + parentlen;
return strncmp(p, dname, dlen);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册