diff --git a/src/services/execution/execute/execution_network.c b/src/services/execution/execute/execution_network.c index 43be0fbdf41b0cd43977a33e57427e0ca03769f4..7c2febe2c5a5a27b6cb30a1194bb77c24bf9b51f 100644 --- a/src/services/execution/execute/execution_network.c +++ b/src/services/execution/execute/execution_network.c @@ -648,7 +648,6 @@ error_out: static int chown_network(const char *user_remap, const char *rootfs, const char *filename) { int ret = 0; - size_t path_len = 0; char *file_path = NULL; unsigned int host_uid = 0; unsigned int host_gid = 0; @@ -663,20 +662,9 @@ static int chown_network(const char *user_remap, const char *rootfs, const char ret = -1; goto out; } - path_len = strlen(rootfs) + strlen(filename) + 1; - if (path_len > PATH_MAX) { - ERROR("Invalid path length"); - ret = -1; - goto out; - } - file_path = util_common_calloc_s(path_len); - if (file_path == NULL) { - ERROR("Out of memory"); - ret = -1; - goto out; - } - if (sprintf_s(file_path, path_len, "%s%s", rootfs, filename) < 0) { - ERROR("Failed to print string"); + if (realpath_in_scope(rootfs, filename, &file_path) < 0) { + SYSERROR("Failed to get real path '%s' under rootfs '%s'", filename, rootfs); + lcrd_set_error_message("Failed to get real path '%s' under rootfs '%s'", filename, rootfs); ret = -1; goto out; }