From: Qiumiao Zhang Date: Wed, 25 Oct 2023 03:54:57 +0000 (+0800) Subject: util/grub-mount: Check file path sanity X-Git-Tag: grub-2.12~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f79e3b158bc4aeef94220db676071cfe69e8a5f;p=thirdparty%2Fgrub.git 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 --- 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;