]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/fs/zfs.c: Avoid divisions by zero.
authorVladimir Serbinenko <phcoder@gmail.com>
Tue, 20 Jan 2015 16:46:55 +0000 (17:46 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Wed, 21 Jan 2015 16:42:12 +0000 (17:42 +0100)
ChangeLog
grub-core/fs/zfs/zfs.c

index 8e38fdd4293862cb870bcdaa5b8e8e8242294e55..c60a231e283d25f58f925d12c435cc2154797287 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-01-20  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/fs/zfs.c: Avoid divisions by zero.
+
 2015-01-20  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/fs/btrfs.c: Avoid divisions by zero.
index cfb25c030de2b1097345219aa13fcca52b72c237..c943b5299db73d12fb8dbedf2bcfcb29d5b0140e 100644 (file)
@@ -1501,6 +1501,9 @@ read_device (grub_uint64_t offset, struct grub_zfs_device_desc *desc,
          return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, 
                             "raidz%d is not supported", desc->nparity);
 
+       if (desc->n_children <= desc->nparity || desc->n_children < 1)
+         return grub_error(GRUB_ERR_BAD_FS, "too little devices for given parity");
+
        orig_s = (((len + (1 << desc->ashift) - 1) >> desc->ashift)
                  + (desc->n_children - desc->nparity) - 1);
        s = orig_s;
@@ -2804,6 +2807,9 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn,
                                          dnode_path->dn.endian)
                       << SPA_MINBLOCKSHIFT);
 
+             if (blksz == 0)
+               return grub_error(GRUB_ERR_BAD_FS, "0-sized block");
+
              sym_value = grub_malloc (sym_sz);
              if (!sym_value)
                return grub_errno;
@@ -3798,6 +3804,12 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len)
   blksz = grub_zfs_to_cpu16 (data->dnode.dn.dn_datablkszsec, 
                             data->dnode.endian) << SPA_MINBLOCKSHIFT;
 
+  if (blksz == 0)
+    {
+      grub_error (GRUB_ERR_BAD_FS, "0-sized block");
+      return -1;
+    }
+
   /*
    * Entire Dnode is too big to fit into the space available.  We
    * will need to read it in chunks.  This could be optimized to