From 2ae254de139e95f39950dba74b1d731bc7658505 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 25 Dec 2011 22:07:15 +0100 Subject: [PATCH] * grub-core/fs/affs.c (grub_affs_label): Interpret label as latin1. --- ChangeLog | 4 ++++ grub-core/fs/affs.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index aa3843db0..c64c63b48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-12-25 Vladimir Serbinenko + + * grub-core/fs/affs.c (grub_affs_label): Interpret label as latin1. + 2011-12-25 Vladimir Serbinenko * grub-core/normal/menu.c (menu_init): Don't stop menu init at gfxterm. diff --git a/grub-core/fs/affs.c b/grub-core/fs/affs.c index 0ad5e6672..b551cfcdb 100644 --- a/grub-core/fs/affs.c +++ b/grub-core/fs/affs.c @@ -526,6 +526,7 @@ grub_affs_label (grub_device_t device, char **label) data = grub_affs_mount (disk); if (data) { + grub_size_t len; /* The rootblock maps quite well on a file header block, it's something we can use here. */ grub_disk_read (data->disk, grub_be_to_cpu32 (data->bblock.rootblock), @@ -535,7 +536,10 @@ grub_affs_label (grub_device_t device, char **label) if (grub_errno) return 0; - *label = grub_strndup ((char *) (file.name), file.namelen); + len = grub_min (file.namelen, sizeof (file.name)); + *label = grub_malloc (len * GRUB_MAX_UTF8_PER_LATIN1 + 1); + if (*label) + *grub_latin1_to_utf8 ((grub_uint8_t *) *label, file.name, len) = '\0'; } else *label = 0;