1 From 475bffeae67fa0f6787c33147c120b40e89b1985 Mon Sep 17 00:00:00 2001
2 From: Vladimir Serbinenko <phcoder@gmail.com>
3 Date: Tue, 20 Jan 2015 16:46:55 +0000
4 Subject: * grub-core/fs/zfs.c: Avoid divisions by zero.
7 (limited to 'grub-core/fs/zfs')
9 diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c
10 index cfb25c0..c943b52 100644
11 --- a/grub-core/fs/zfs/zfs.c
12 +++ b/grub-core/fs/zfs/zfs.c
13 @@ -1501,6 +1501,9 @@ read_device (grub_uint64_t offset, struct grub_zfs_device_desc *desc,
14 return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
15 "raidz%d is not supported", desc->nparity);
17 + if (desc->n_children <= desc->nparity || desc->n_children < 1)
18 + return grub_error(GRUB_ERR_BAD_FS, "too little devices for given parity");
20 orig_s = (((len + (1 << desc->ashift) - 1) >> desc->ashift)
21 + (desc->n_children - desc->nparity) - 1);
23 @@ -2804,6 +2807,9 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn,
24 dnode_path->dn.endian)
25 << SPA_MINBLOCKSHIFT);
28 + return grub_error(GRUB_ERR_BAD_FS, "0-sized block");
30 sym_value = grub_malloc (sym_sz);
33 @@ -3798,6 +3804,12 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len)
34 blksz = grub_zfs_to_cpu16 (data->dnode.dn.dn_datablkszsec,
35 data->dnode.endian) << SPA_MINBLOCKSHIFT;
39 + grub_error (GRUB_ERR_BAD_FS, "0-sized block");
44 * Entire Dnode is too big to fit into the space available. We
45 * will need to read it in chunks. This could be optimized to