Skip to contentSkip to conversation

util/grub-mount: Check file path sanity

PATCH In review Qiumiao Zhang via Grub-devel 2 participants 2 messages Oct 25, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 util/grub-mount: Check file path sanity

In grub-mount.c, the function argp_parser() 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.

---
 util/grub-mount.c | 2 ++
 1 file changed, 2 insertions(+)
util/grub-mount.c +2 -0
index c69889df9..1d353f0df 100644
@@ -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;
Signature · 7 lines
2.28.0.windows.1


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Qiumiao Zhang via Grub-devel

In grub-mount.c, the function argp_parser() 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.

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel