]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/net/drivers/efi/efinet.c (get_card_packet): Fix buffer
authorBean <bean123ch@gmail.com>
Sun, 29 Apr 2012 16:43:22 +0000 (18:43 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 29 Apr 2012 16:43:22 +0000 (18:43 +0200)
allocation.

ChangeLog
grub-core/net/drivers/efi/efinet.c

index e18d3d2e9355964320d8ac3d87009a8580fdccf5..dbcbd6d6e4f7be229c00c32ba49816d51cff7602 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-04-29  Bean  <bean123ch@gmail.com>
+
+       * grub-core/net/drivers/efi/efinet.c (get_card_packet): Fix buffer
+       allocation.
+
 2012-04-29  Mads Kiilerich  <mads@kiilerich.com> (tiny)
 
        * configure.ac: Detect starfield theme font path
index 78a1eab16cf505844fef2c5b553a8dde686c9da3..2313103de9f3d4f49326f4811f84607d7f97691b 100644 (file)
@@ -63,14 +63,13 @@ get_card_packet (const struct grub_net_card *dev)
   grub_efi_uintn_t bufsize = 1536;
   struct grub_net_buff *nb;
 
-  nb = grub_netbuff_alloc (bufsize);
+  nb = grub_netbuff_alloc (bufsize + 2);
   if (!nb)
     return NULL;
 
   /* Reserve 2 bytes so that 2 + 14/18 bytes of ethernet header is divisible
      by 4. So that IP header is aligned on 4 bytes. */
-  grub_netbuff_reserve (nb, 2);
-  if (!nb)
+  if (grub_netbuff_reserve (nb, 2))
     {
       grub_netbuff_free (nb);
       return NULL;
@@ -84,14 +83,13 @@ get_card_packet (const struct grub_net_card *dev)
 
       bufsize = ALIGN_UP (bufsize, 32);
 
-      nb = grub_netbuff_alloc (bufsize);
+      nb = grub_netbuff_alloc (bufsize + 2);
       if (!nb)
        return NULL;
 
       /* Reserve 2 bytes so that 2 + 14/18 bytes of ethernet header is divisible
         by 4. So that IP header is aligned on 4 bytes. */
-      grub_netbuff_reserve (nb, 2);
-      if (!nb)
+      if (grub_netbuff_reserve (nb, 2))
        {
          grub_netbuff_free (nb);
          return NULL;