]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/fs/affs.c (grub_affs_read_symlink): Fix handling of long
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 12 May 2012 11:44:48 +0000 (13:44 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 12 May 2012 11:44:48 +0000 (13:44 +0200)
symlinks. Replace leading colon with a slash.

ChangeLog
grub-core/fs/affs.c

index 14feffd3e0b4a1d4d89aecc3a1fc4d458a67149a..7c8c067e60523d23ba508350778cd260f88013d7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-05-12  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * 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  <phcoder@gmail.com>
 
        * grub-core/fs/jfs.c (grub_jfs_find_file): Handle multiple slashes in
index e88d06980944aae11227fae8eb60da15cf5d6c39..48f9717fa7b617670452db92cfa536c6e094fc19 100644 (file)
@@ -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;
 }