When reading strings from a USB device in grub_usb_get_string() function the initial length is taken from first message read. Then this value is used to allocate memory for UTF-8 destination string. However, during conversion the length value is taken from the second USB device read. This can be dangerous if malicious USB devices are connected because they may expose smaller initial length value, used for memory allocation, and subsequent read may provide larger length, used during conversion. Such behavior may lead to heap overflow during UTF-16 to UTF-8 conversion.