Skip to content

Commit 17135c1

Browse files
committed
chroot_realpath: do not return non-existing paths
Do not return non-existing paths in chroot_realpath(). Rationale: failing early is good. Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
1 parent a029af2 commit 17135c1

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

src/libcrun/chroot_realpath.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,6 @@ char *chroot_realpath(const char *chroot, const char *path, char resolved_path[]
133133
*new_path = '\0';
134134
n = readlink(got_path, link_path, PATH_MAX - 1);
135135
if (n < 0) {
136-
/* If a component doesn't exist, then return what we could translate. */
137-
if (errno == ENOENT) {
138-
sprintf (resolved_path, "%s%s%s", got_path, path[0] == '/' || path[0] == '\0' ? "" : "/", path);
139-
return resolved_path;
140-
}
141136
/* EINVAL means the file exists but isn't a symlink. */
142137
if (errno != EINVAL) {
143138
/* Make sure it's null terminated. */

0 commit comments

Comments
 (0)