From 3f79e3b158bc4aeef94220db676071cfe69e8a5f Mon Sep 17 00:00:00 2001 From: Qiumiao Zhang Date: Wed, 25 Oct 2023 11:54:57 +0800 Subject: [PATCH] util/grub-mount: Check file path sanity The function argp_parser() in util/grub-mount.c lacks a check on the sanity of the file path when parsing parameters. This results in a segmentation fault if a partition is mounted to a non-existent path. Signed-off-by: Qiumiao Zhang Reviewed-by: Daniel Kiper --- util/grub-mount.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/grub-mount.c b/util/grub-mount.c index c69889df9..bf4c8b891 100644 --- a/util/grub-mount.c +++ b/util/grub-mount.c @@ -563,6 +563,8 @@ argp_parser (int key, char *arg, struct argp_state *state) images = xrealloc (images, (num_disks + 1) * sizeof (images[0])); images[num_disks] = grub_canonicalize_file_name (arg); + if (images[num_disks] == NULL) + grub_util_error (_("cannot find `%s': %s"), arg, strerror (errno)); num_disks++; return 0;