]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
commands/usbtest: Ensure string length is sufficient in usb string processing
authorJamie <volticks@gmail.com>
Mon, 14 Jul 2025 09:07:47 +0000 (10:07 +0100)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 18 Nov 2025 13:34:44 +0000 (14:34 +0100)
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.

Signed-off-by: Jamie <volticks@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/commands/usbtest.c

index 8ef187a9ae765c409a8039b7b00d62d750e60eee..3184ac9afd3737a9a25b8d7736a035428f12761e 100644 (file)
@@ -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 ("");