]> git.proxmox.com Git - grub2.git/commitdiff
* util/grub-setup.c (setup): Handle some corner cases.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 4 Apr 2013 06:55:06 +0000 (08:55 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 4 Apr 2013 06:55:06 +0000 (08:55 +0200)
ChangeLog
util/grub-setup.c

index 467a6217f942b359e06271de5546a27014b827c2..8a3fd454666962cc84a6be1af5f93457a27bdd6c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-04-04  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * util/grub-setup.c (setup): Handle some corner cases.
+
 2013-04-04  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/lib/posix_wrap/locale.h [GRUB_UTIL]: Include host locale.h.
index 5a7a85773f6ea509e0bf998cf83b6ab587329a74..27a815f2e0a91d8ca90e2ebef0b8335b8332d499 100644 (file)
@@ -256,7 +256,7 @@ setup (const char *dir,
   grub_device_t root_dev = 0, dest_dev, core_dev;
   struct blocklists bl;
   char *tmp_img;
-  grub_disk_addr_t first_sector;
+  grub_disk_addr_t first_sector = (grub_disk_addr_t)-1;
   FILE *fp;
 
 #ifdef GRUB_SETUP_BIOS
@@ -756,6 +756,8 @@ unable_to_embed:
          grub_util_error ("%s", _("blocksize is not divisible by 512"));
        mul = bsize >> GRUB_DISK_SECTOR_BITS;
        nblocks = (core_size + bsize - 1) / bsize;
+       if (mul == 0 || nblocks == 0)
+         grub_util_error ("%s", _("can't retrieve blocklists"));
        for (i = 0; i < nblocks; i++)
          {
            unsigned blk = i;
@@ -808,7 +810,7 @@ unable_to_embed:
                              - j * GRUB_DISK_SECTOR_SIZE);
                if (len > GRUB_DISK_SECTOR_SIZE)
                  len = GRUB_DISK_SECTOR_SIZE;
-               if (i == 0 && j == 0)
+               if (first_sector == (grub_disk_addr_t)-1)
                  save_first_sector ((fie2->fm_extents[i].fe_physical
                                      >> GRUB_DISK_SECTOR_BITS)
                                     + j + container_start,
@@ -825,6 +827,8 @@ unable_to_embed:
 
              }
          }
+       if (first_sector == (grub_disk_addr_t)-1)
+         grub_util_error ("%s", _("can't retrieve blocklists"));
       }
     fclose (fp);
   }