* 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.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-12-13 01:41:16 +01:00
parent 53072f9b96
commit 78c2cd1c62
4 changed files with 10 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2011-12-13 Vladimir Serbinenko <phcoder@gmail.com>
* 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 <phcoder@gmail.com>
* grub-core/term/at_keyboard.c (set_scancodes): Fix preprocessor

View File

@ -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)
{

View File

@ -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));

View File

@ -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);