Skip to contentSkip to conversation

commands/usbtest: Ensure string length is sufficient in usb string processing

PATCH In review Daniel Kiper via Grub-devel 1 participant 1 message Nov 18, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 8/8 commands/usbtest: Ensure string length is sufficient in usb string processing

From: Jamie <[email protected]>

If descstrp->length is less than 2 this will result in underflow in "descstrp->length / 2 - 1" math. Let's fix the check to make sure the value is sufficient.

---
 grub-core/commands/usbtest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/commands/usbtest.c +1 -1
index 8ef187a9a..3184ac9af 100644
@@ -90,7 +90,7 @@ grub_usb_get_string (grub_usb_device_t dev, grub_uint8_t index, int langid,
 			      0x06, (3 << 8) | index,
 			      langid, descstr.length, (char *) descstrp);
 
-  if (descstrp->length == 0)
+  if (descstrp->length < 2)
     {
       grub_free (descstrp);
       *string = grub_strdup ("");
Signature · 7 lines
2.11.0


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