From f1312256542233a106d085e5d5ac56006ed82edc Mon Sep 17 00:00:00 2001 From: Ritvik Date: Fri, 24 Nov 2023 20:01:30 -0500 Subject: [PATCH] Fix checking sscanf return value as the value can be 0 causing overflow in snprintf --- grub-core/osdep/linux/ofpath.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index cc849d9c94..d89a348ee2 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -292,6 +292,8 @@ __of_path_common(char *sysfs_path, int part; sscanf(digit_string, "%d", &part); + if (part < 1) + return NULL; snprintf(disk, sizeof (disk), "/disk@%d:%c", devno, 'a' + (part - 1)); } strcat(of_path, disk);