Eliminate grub_min/grub_max prone to overflow usage.
* grub-core/bus/usb/usbhub.c (grub_usb_add_hub): Eliminate grub_min. (poll_nonroot_hub): Likewise. * grub-core/fs/affs.c (grub_affs_iterate_dir): Likewise. (grub_affs_label): Likewise. * grub-core/fs/btrfs.c (grub_btrfs_lzo_decompress): Likewise. * grub-core/fs/hfs.c (grub_hfs_dir): Likewise. (grub_hfs_label): Likewise. * grub-core/fs/hfsplus.c (grub_hfsplus_cmp_catkey): Likewise. * grub-core/fs/zfs/zfs.c (MIN): Remove. (zap_leaf_array_equal): Use grub_size. Remove MIN. (zap_leaf_array_get): Likewise. (dnode_get_path): Likewise. * grub-core/io/lzopio.c (grub_lzopio_read): Eliminate grub_min. * grub-core/io/xzio.c (grub_xzio_read): Likewise. * grub-core/script/execute.c (grub_script_break): Likewise. * grub-core/script/lexer.c (grub_script_lexer_record): Eliminate grub_max. * grub-core/script/yylex.l (grub_lexer_yyrealloc): Likewise. * include/grub/misc.h (grub_min): Removed. (grub_max): Likewise.
This commit is contained in:
parent
80662dbc5d
commit
9c2710789f
13 changed files with 97 additions and 57 deletions
|
@ -305,6 +305,7 @@ grub_affs_iterate_dir (grub_fshelp_node_t dir,
|
|||
{
|
||||
int type;
|
||||
grub_uint8_t name_u8[sizeof (fil->name) * GRUB_MAX_UTF8_PER_LATIN1 + 1];
|
||||
grub_size_t len;
|
||||
|
||||
node = grub_zalloc (sizeof (*node));
|
||||
if (!node)
|
||||
|
@ -327,8 +328,10 @@ grub_affs_iterate_dir (grub_fshelp_node_t dir,
|
|||
node->di = *fil;
|
||||
node->parent = dir;
|
||||
|
||||
*grub_latin1_to_utf8 (name_u8, fil->name,
|
||||
grub_min (fil->namelen, sizeof (fil->name))) = '\0';
|
||||
len = fil->namelen;
|
||||
if (len > sizeof (fil->name))
|
||||
len = sizeof (fil->name);
|
||||
*grub_latin1_to_utf8 (name_u8, fil->name, len) = '\0';
|
||||
|
||||
if (hook ((char *) name_u8, type, node))
|
||||
{
|
||||
|
@ -540,7 +543,9 @@ grub_affs_label (grub_device_t device, char **label)
|
|||
if (grub_errno)
|
||||
return 0;
|
||||
|
||||
len = grub_min (file.namelen, sizeof (file.name));
|
||||
len = file.namelen;
|
||||
if (len > sizeof (file.name))
|
||||
len = sizeof (file.name);
|
||||
*label = grub_malloc (len * GRUB_MAX_UTF8_PER_LATIN1 + 1);
|
||||
if (*label)
|
||||
*grub_latin1_to_utf8 ((grub_uint8_t *) *label, file.name, len) = '\0';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue