libselinux: src: matchpathcon: make sure resolved path starts with /
Resolving paths from relative to absolute didn't always start with a /. Make sure they start with a /. Signed-off-by: Eric Paris <eparis@redhat.com>
This commit is contained in:
parent
09b635fa20
commit
7bfaa63839
|
@ -381,14 +381,17 @@ static int symlink_realpath(const char *name, char *resolved_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strlen(p);
|
len = strlen(p);
|
||||||
if (len + strlen(last_component) + 1 > PATH_MAX) {
|
if (len + strlen(last_component) + 2 > PATH_MAX) {
|
||||||
myprintf("symlink_realpath(%s) failed: Filename too long \n",
|
myprintf("symlink_realpath(%s) failed: Filename too long \n",
|
||||||
name);
|
name);
|
||||||
|
errno=ENAMETOOLONG;
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
resolved_path += len;
|
resolved_path += len;
|
||||||
|
strcpy(resolved_path, "/");
|
||||||
|
resolved_path += 1;
|
||||||
strcpy(resolved_path, last_component);
|
strcpy(resolved_path, last_component);
|
||||||
out:
|
out:
|
||||||
free(tmp_path);
|
free(tmp_path);
|
||||||
|
|
Loading…
Reference in New Issue