mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-21 14:59:34 +00:00
fs/zfs: Prevent overflows when allocating memory for arrays
Use grub_calloc() when allocating memory for arrays to ensure proper overflow checks are in place. Signed-off-by: Lidong Chen <lidong.chen@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
88e491a0f7
commit
7f38e32c7e
1 file changed
+4
-4
@@ -763,8 +763,8 @@ fill_vdev_info_real (struct grub_zfs_data *data,
|
|||||||
{
|
{
|
||||||
fill->n_children = nelm;
|
fill->n_children = nelm;
|
||||||
|
|
||||||
fill->children = grub_zalloc (fill->n_children
|
fill->children = grub_calloc (fill->n_children,
|
||||||
* sizeof (fill->children[0]));
|
sizeof (fill->children[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nelm; i++)
|
for (i = 0; i < nelm; i++)
|
||||||
@@ -3752,8 +3752,8 @@ zfs_mount (grub_device_t dev)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
data->n_devices_allocated = 16;
|
data->n_devices_allocated = 16;
|
||||||
data->devices_attached = grub_malloc (sizeof (data->devices_attached[0])
|
data->devices_attached = grub_calloc (data->n_devices_allocated,
|
||||||
* data->n_devices_allocated);
|
sizeof (data->devices_attached[0]));
|
||||||
data->n_devices_attached = 0;
|
data->n_devices_attached = 0;
|
||||||
err = scan_disk (dev, data, 1, &inserted);
|
err = scan_disk (dev, data, 1, &inserted);
|
||||||
if (err)
|
if (err)
|
||||||
|
|||||||
Reference in new issue
Block a user