Skip to content

Commit 16b7ae4

Browse files
authored
Merge pull request #1742 from kolyshkin/criu-2
criu: validate --parent-path
2 parents 9d48af5 + 91aa368 commit 16b7ae4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/libcrun/criu.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,16 @@ libcrun_container_checkpoint_linux_criu (libcrun_container_status_t *status, lib
508508
if (UNLIKELY (criu_can_mem_track == -1))
509509
return -1;
510510
libcriu_wrapper->criu_set_track_mem (true);
511-
/* The parent path needs to be a relative path. CRIU will fail
512-
* if the path is not in the right format. Usually something like
513-
* ../previous-dump */
511+
512+
/* The parent path must be relative to image path (something like ../previous-dump).
513+
CRIU will fail with an unclear error message if the path is not right.
514+
*/
515+
if (UNLIKELY (cr_options->parent_path[0] == '/'))
516+
return crun_make_error (err, 0, "--parent-path must be relative");
517+
int is_dir = crun_dir_p_at (image_fd, cr_options->parent_path, false, err);
518+
if (UNLIKELY (is_dir <= 0))
519+
return crun_make_error (err, is_dir < 0 ? errno : ENOTDIR, "invalid --parent-path");
520+
514521
ret = libcriu_wrapper->criu_set_parent_images (cr_options->parent_path);
515522
if (UNLIKELY (ret != 0))
516523
return crun_make_error (err, -ret, "error setting CRIU parent images path to `%s`", cr_options->parent_path);

0 commit comments

Comments
 (0)