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:
Eric Paris 2011-09-15 17:58:52 -04:00
parent 09b635fa20
commit 7bfaa63839
1 changed files with 4 additions and 1 deletions

View File

@ -381,14 +381,17 @@ static int symlink_realpath(const char *name, char *resolved_path)
}
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",
name);
errno=ENAMETOOLONG;
rc = -1;
goto out;
}
resolved_path += len;
strcpy(resolved_path, "/");
resolved_path += 1;
strcpy(resolved_path, last_component);
out:
free(tmp_path);