From 33eca6e005740120ac4f14fc81ecc34ed145d641 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 12 May 2012 13:44:48 +0200 Subject: [PATCH] * grub-core/fs/affs.c (grub_affs_read_symlink): Fix handling of long symlinks. Replace leading colon with a slash. --- ChangeLog | 5 +++++ grub-core/fs/affs.c | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 14feffd3e..7c8c067e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-05-12 Vladimir Serbinenko + + * grub-core/fs/affs.c (grub_affs_read_symlink): Fix handling of long + symlinks. Replace leading colon with a slash. + 2012-05-12 Vladimir Serbinenko * grub-core/fs/jfs.c (grub_jfs_find_file): Handle multiple slashes in diff --git a/grub-core/fs/affs.c b/grub-core/fs/affs.c index e88d06980..48f9717fa 100644 --- a/grub-core/fs/affs.c +++ b/grub-core/fs/affs.c @@ -280,9 +280,9 @@ grub_affs_read_symlink (grub_fshelp_node_t node) struct grub_affs_data *data = node->data; grub_uint8_t *latin1, *utf8; const grub_size_t symlink_size = ((GRUB_DISK_SECTOR_SIZE - << data->log_blocksize) - 225); + << data->log_blocksize) - GRUB_AFFS_SYMLINK_OFFSET); - latin1 = grub_malloc (symlink_size); + latin1 = grub_malloc (symlink_size + 1); if (!latin1) return 0; @@ -295,6 +295,7 @@ grub_affs_read_symlink (grub_fshelp_node_t node) grub_free (latin1); return 0; } + latin1[symlink_size] = 0; utf8 = grub_malloc (symlink_size * GRUB_MAX_UTF8_PER_LATIN1 + 1); if (!utf8) { @@ -304,6 +305,8 @@ grub_affs_read_symlink (grub_fshelp_node_t node) *grub_latin1_to_utf8 (utf8, latin1, symlink_size) = '\0'; grub_dprintf ("affs", "Symlink: `%s'\n", utf8); grub_free (latin1); + if (utf8[0] == ':') + utf8[0] = '/'; return (char *) utf8; }