]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/kern/i386/qemu/init.c: Remove variable length arrays.
authorVladimir Serbinenko <phcoder@gmail.com>
Wed, 4 Dec 2013 08:48:36 +0000 (09:48 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Wed, 4 Dec 2013 08:48:36 +0000 (09:48 +0100)
ChangeLog
grub-core/kern/i386/qemu/init.c

index 38e128462d45f97c758bbc484d4d06ab44600ffe..2772581482550a808545dee0c6d41e5a5d3e4ef3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-12-04  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/kern/i386/qemu/init.c: Remove variable length arrays.
+
 2013-12-04  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * include/grub/types.h: Declare all byteswaps as inline functions
index e05ccee965633b539dd91c9a8121b7b9ca37ea3e..09da1e97f5246e7f6af95a3b7e59c92f7d518a48 100644 (file)
@@ -96,17 +96,8 @@ struct iterator_ctx
   grub_size_t nresources;
 };
 
-static int
-count_cards (grub_pci_device_t dev __attribute__ ((unused)),
-            grub_pci_id_t pciid __attribute__ ((unused)),
-            void *data)
-{
-  int *cnt = data;
-
-  (*cnt)++;
-
-  return 0;
-}
+/* We don't support bridges, so can't have more than 32 devices.  */
+#define MAX_DEVICES 32
 
 static int
 find_resources (grub_pci_device_t dev,
@@ -116,6 +107,9 @@ find_resources (grub_pci_device_t dev,
   struct iterator_ctx *ctx = data;
   int bar;
 
+  if (ctx->nresources >= MAX_DEVICES * 6)
+    return 1;
+
   for (bar = 0; bar < 6; bar++)
     {
       grub_pci_address_t addr;
@@ -190,13 +184,10 @@ enable_cards (grub_pci_device_t dev,
 static void
 grub_pci_assign_addresses (void)
 {
-  int ncards = 0;
   struct iterator_ctx ctx;
 
-  grub_pci_iterate (count_cards, &ncards);
-
   {
-    struct resource resources[ncards * 6];
+    struct resource resources[MAX_DEVICES * 6];
     int done;
     unsigned i;
     ctx.nresources = 0;