]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/fs/ntfs.c: Remove variable length arrays.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 20 Oct 2013 15:35:17 +0000 (17:35 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 20 Oct 2013 15:35:17 +0000 (17:35 +0200)
Increases ntfs.mod by 64 bytes (but decreases by 3 when
compressed).

ChangeLog
grub-core/fs/ntfs.c

index 659096fd39a4d20a4e4ae52515d2ee63efe81231..943e6d89a084faea8c29fa272966ae67e93a4f31 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-10-20  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/fs/ntfs.c: Remove variable length arrays.
+       Increases ntfs.mod by 64 bytes (but decreases by 3 when
+       compressed).
+
 2013-10-20  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/fs/hfs.c: Remove variable length arrays.
 2013-10-20  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/fs/udf.c: Remove variable length arrays.
-       Increases udf.mod by 128 bytes (but decreases by 13 compressed when
+       Increases udf.mod by 128 bytes (but decreases by 13 when
        compressed).
 
 2013-10-20  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/fs/iso9660.c: Remove variable length arrays.
-       Increases iso9660.mod by 200 bytes (but decreases by 79 compressed when
+       Increases iso9660.mod by 200 bytes (but decreases by 79 when
        compressed).
 
 2013-10-20  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/fs/nilfs2.c: Remove variable length arrays.
-       Increases nilfs2.mod by 24 bytes (but decreases by 115 compressed when
+       Increases nilfs2.mod by 24 bytes (but decreases by 115 when
        compressed).
 
 2013-10-20  Vladimir Serbinenko  <phcoder@gmail.com>
index 5ea2e1bd750926c57b887b7b37fdd3fe15e598dd..d342e45c5f43ca680e621101f63236a54fb58ba9 100644 (file)
@@ -643,7 +643,7 @@ list_file (struct grub_ntfs_file *diro, grub_uint8_t *pos,
          if (ustr == NULL)
            return 0;
          {
-           grub_uint16_t tmp[ns];
+           grub_uint16_t tmp[256];
            int i;
            for (i = 0; i < ns; i++)
              tmp[i] = grub_le_to_cpu16 (grub_get_unaligned16 ((char *) np
@@ -1185,18 +1185,24 @@ grub_ntfs_label (grub_device_t device, char **label)
   if ((pa) && (pa[8] == 0) && (u32at (pa, 0x10)))
     {
       grub_uint8_t *buf;
+      grub_uint16_t *tmp;
       int len;
+      int i;
 
       len = u32at (pa, 0x10) / 2;
       buf = grub_malloc (len * 4 + 1);
+      tmp = grub_malloc (len * 2);
+      if (!buf || !tmp)
+       {
+         grub_free (buf);
+         grub_free (tmp);
+         goto fail;
+       }
       pa += u16at (pa, 0x14);
-      {
-       grub_uint16_t tmp[len];
-       int i;
-       for (i = 0; i < len; i++)
-         tmp[i] = grub_le_to_cpu16 (grub_get_unaligned16 (pa + 2 * i));
-       *grub_utf16_to_utf8 (buf, tmp, len) = '\0';
-      }
+      for (i = 0; i < len; i++)
+       tmp[i] = grub_le_to_cpu16 (grub_get_unaligned16 (pa + 2 * i));
+      *grub_utf16_to_utf8 (buf, tmp, len) = '\0';
+      grub_free (tmp);
       *label = (char *) buf;
     }