diff --git a/ChangeLog b/ChangeLog index 088f6f848..0780a3691 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-12-13 Vladimir Serbinenko + + * grub-core/fs/udf.c (read_string): Macroify GRUB_MAX_UTF8_PER_UTF16. + * grub-core/fs/jfs.c (grub_jfs_diropen): Likewise. + * grub-core/fs/fat.c (grub_fat_iterate_dir): Likewise. + 2011-12-13 Vladimir Serbinenko * grub-core/term/at_keyboard.c (set_scancodes): Fix preprocessor diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c index 0d32e229d..0569120fb 100644 --- a/grub-core/fs/fat.c +++ b/grub-core/fs/fat.c @@ -589,7 +589,7 @@ grub_fat_iterate_dir (grub_disk_t disk, struct grub_fat_data *data, char *filename; unibuf = grub_malloc (15 * 256 * 2); - filename = grub_malloc (15 * 256 * 4 + 1); + filename = grub_malloc (15 * 256 * GRUB_MAX_UTF8_PER_UTF16 + 1); while (1) { @@ -696,7 +696,7 @@ grub_fat_iterate_dir (grub_disk_t disk, struct grub_fat_data *data, return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); /* Allocate space enough to hold a long name. */ - filename = grub_malloc (0x40 * 13 * 4 + 1); + filename = grub_malloc (0x40 * 13 * GRUB_MAX_UTF8_PER_UTF16 + 1); unibuf = (grub_uint16_t *) grub_malloc (0x40 * 13 * 2); if (! filename || ! unibuf) { diff --git a/grub-core/fs/jfs.c b/grub-core/fs/jfs.c index 91497f143..3554803cb 100644 --- a/grub-core/fs/jfs.c +++ b/grub-core/fs/jfs.c @@ -241,7 +241,7 @@ struct grub_jfs_diropen /* On-disk name is at most 255 UTF-16 codepoints. Every UTF-16 codepoint is at most 4 UTF-8 bytes. */ - char name[256 * 4 + 1]; + char name[256 * GRUB_MAX_UTF8_PER_UTF16 + 1]; grub_uint32_t ino; } __attribute__ ((packed)); diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c index e1f115015..4097fd2e6 100644 --- a/grub-core/fs/udf.c +++ b/grub-core/fs/udf.c @@ -820,7 +820,7 @@ read_string (grub_uint8_t *raw, grub_size_t sz) for (i = 0; i < utf16len; i++) utf16[i] = (raw[2 * i + 1] << 8) | raw[2*i + 2]; } - ret = grub_malloc (utf16len * 3 + 1); + ret = grub_malloc (utf16len * GRUB_MAX_UTF8_PER_UTF16 + 1); if (ret) *grub_utf16_to_utf8 ((grub_uint8_t *) ret, utf16, utf16len) = '\0'; grub_free (utf16);