mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-24 08:09:22 +00:00
calloc: Use calloc() at most places
This modifies most of the places we do some form of:
X = malloc(Y * Z);
to use calloc(Y, Z) instead.
Among other issues, this fixes:
- allocation of integer overflow in grub_png_decode_image_header()
reported by Chris Coulson,
- allocation of integer overflow in luks_recover_key()
reported by Chris Coulson,
- allocation of integer overflow in grub_lvm_detect()
reported by Chris Coulson.
Fixes: CVE-2020-14308
Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
64e26162eb
commit
f725fa7cb2
87 files changed
+179
-178
No files matched your search
+3
-3
@@ -301,7 +301,7 @@ grub_affs_read_symlink (grub_fshelp_node_t node)
|
||||
return 0;
|
||||
}
|
||||
latin1[symlink_size] = 0;
|
||||
utf8 = grub_malloc (symlink_size * GRUB_MAX_UTF8_PER_LATIN1 + 1);
|
||||
utf8 = grub_calloc (GRUB_MAX_UTF8_PER_LATIN1 + 1, symlink_size);
|
||||
if (!utf8)
|
||||
{
|
||||
grub_free (latin1);
|
||||
@@ -422,7 +422,7 @@ grub_affs_iterate_dir (grub_fshelp_node_t dir,
|
||||
return 1;
|
||||
}
|
||||
|
||||
hashtable = grub_zalloc (data->htsize * sizeof (*hashtable));
|
||||
hashtable = grub_calloc (data->htsize, sizeof (*hashtable));
|
||||
if (!hashtable)
|
||||
return 1;
|
||||
|
||||
@@ -628,7 +628,7 @@ grub_affs_label (grub_device_t device, char **label)
|
||||
len = file.namelen;
|
||||
if (len > sizeof (file.name))
|
||||
len = sizeof (file.name);
|
||||
*label = grub_malloc (len * GRUB_MAX_UTF8_PER_LATIN1 + 1);
|
||||
*label = grub_calloc (GRUB_MAX_UTF8_PER_LATIN1 + 1, len);
|
||||
if (*label)
|
||||
*grub_latin1_to_utf8 ((grub_uint8_t *) *label, file.name, len) = '\0';
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user