Skip to content

Commit

Permalink
lkl/tests: add disk parameters check to avoid segfaulting
Browse files Browse the repository at this point in the history
Check for disk (image) and fstype parameters, to avoid segfaulting
immediately. Failure to open the image or invalid fstype will still
result in segfault.

Signed-off-by: David Disseldorp <[email protected]>
  • Loading branch information
ddiss committed Sep 8, 2023
1 parent db1e78e commit 2908898
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tools/lkl/tests/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static int lkl_test_opendir(void)

dir = lkl_opendir(mnt_point, &err);

lkl_test_logf("lkl_opedir(%s) = %d %s\n", mnt_point, err,
lkl_test_logf("lkl_opendir(%s) = %d %s\n", mnt_point, err,
lkl_strerror(err));

if (err == 0)
Expand Down Expand Up @@ -182,6 +182,11 @@ int main(int argc, const char **argv)
if (parse_args(argc, argv, args) < 0)
return -1;

if (!cla.disk || !cla.fstype) {
fprintf(stderr, "disk and type parameters required.\n");
return -1;
}

lkl_host_ops.print = lkl_test_log;

lkl_init(&lkl_host_ops);
Expand Down

0 comments on commit 2908898

Please sign in to comment.