[PATCH 1/1] efi_loader: fix device path to text protocol

File device path nodes may contain non-ASCII characters. Correctly truncate the text if it does not fit into the buffer.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com --- lib/efi_loader/efi_device_path_to_text.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c index d8a83c8849..805add7268 100644 --- a/lib/efi_loader/efi_device_path_to_text.c +++ b/lib/efi_loader/efi_device_path_to_text.c @@ -292,10 +292,7 @@ static char *dp_media(char *s, struct efi_device_path *dp) case DEVICE_PATH_SUB_TYPE_FILE_PATH: { struct efi_device_path_file_path *fp = (struct efi_device_path_file_path *)dp; - int slen = (dp->length - sizeof(*dp)) / 2; - if (slen > MAX_NODE_LEN - 2) - slen = MAX_NODE_LEN - 2; - s += sprintf(s, "%-.*ls", slen, fp->str); + s += snprintf(s, MAX_NODE_LEN, "%ls", fp->str); break; } default:
participants (1)
-
Heinrich Schuchardt