]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
osdep/linux/ofpath: Correct path_size calculation
authorNicholas Vinson <nvinson234@gmail.com>
Wed, 25 Feb 2026 00:48:40 +0000 (19:48 -0500)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 26 Feb 2026 14:51:56 +0000 (15:51 +0100)
path_size is computed in part by taking the size of the format string.
However, the format string contains conversion specifiers. These
conversion specifiers are included in the size calculation resulting in
a size calculation that is larger than it needs to be. This patch
corrects that error by removing the conversion specifiers when computing
path_size.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/osdep/linux/ofpath.c

index 0ebfea44cb61a976fa50ceac0ab2637332243a56..38d9bb5bf8d13dd743e6fb494eeb709387940a47 100644 (file)
@@ -507,7 +507,7 @@ check_sas (const char *sysfs_path, int *tgt, unsigned long int *sas_address)
   p_len = (int) (q - sysfs_path);
   ed_len = (int) (q - ed);
 
-  path_size = (p_len + ed_len + sizeof ("%s/sas_device/%s/phy_identifier"));
+  path_size = (p_len + ed_len + sizeof ("/sas_device//phy_identifier"));
   path = xmalloc (path_size);
   snprintf (path, path_size, "%.*s/sas_device/%.*s/phy_identifier", p_len,
            sysfs_path, ed_len, ed);