Commit Graph

11 Commits

Author SHA1 Message Date
Peter Jones 3f05d693d1 malloc: Use overflow checking primitives where we do complex allocations
This attempts to fix the places where we do the following where
arithmetic_expr may include unvalidated data:

  X = grub_malloc(arithmetic_expr);

It accomplishes this by doing the arithmetic ahead of time using grub_add(),
grub_sub(), grub_mul() and testing for overflow before proceeding.

Among other issues, this fixes:
  - allocation of integer overflow in grub_video_bitmap_create()
    reported by Chris Coulson,
  - allocation of integer overflow in grub_png_decode_image_header()
    reported by Chris Coulson,
  - allocation of integer overflow in grub_squash_read_symlink()
    reported by Chris Coulson,
  - allocation of integer overflow in grub_ext2_read_symlink()
    reported by Chris Coulson,
  - allocation of integer overflow in read_section_as_string()
    reported by Chris Coulson.

Fixes: CVE-2020-14309, CVE-2020-14310, CVE-2020-14311

Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-07-29 16:55:47 +02:00
Vladimir 'phcoder' Serbinenko ac6fd21803 * grub-core/script/argv.c (grub_script_argv_split_append): Skip leading
spaces.
	* tests/grub_script_leading_whitespace.in: New file.
	* Makefile.util.def (grub_script_leading_whitespace): New test.
2012-03-19 13:29:43 +01:00
Vladimir 'phcoder' Serbinenko d35d0d3753 Add const keyword to grub_env_get and gettextize week days.
* grub-core/hook/datehook.c (grub_datetime_names): Make const.
	(grub_read_hook_datetime): Return const char *.
	* grub-core/kern/env.c (grub_env_get): Return const char *. All users
	updated.
	* grub-core/normal/datetime.c (grub_weekday_names): Make const.
	Mark for gettext.
	(grub_get_weekday_name): Return const char *. Call gettext.
	* grub-core/script/argv.c (grub_script_argv_append): Receive const
	char * and len as the argument. All users updated.
	(grub_script_argv_split_append): Receive const char *.
	* include/grub/datetime.h (grub_get_weekday_name): Update proto.
	* include/grub/env.h (grub_env_get): Likewise.
	(grub_env_read_hook_t): Return const char *.
	* include/grub/script_sh.h (grub_script_argv_append): Update proto.
	(grub_script_argv_split_append): Likewise.
2011-11-11 20:34:37 +01:00
Vladimir 'phcoder' Serbinenko 80f23be71f * grub-core/script/argv.c (round_up_exp): unsigned is 32-bit on all
supported platforms. Put a compile time assert for this rather than
	generate a warning with 32-bit shift.
2011-01-22 14:11:19 +01:00
BVK Chaitanya ee14ec9935 merge with mainline 2010-09-04 22:34:32 +05:30
BVK Chaitanya 6d7c073bc8 merge with mainline 2010-09-04 11:49:02 +05:30
BVK Chaitanya 227cab7c79 merge with mainline 2010-09-04 10:56:23 +05:30
BVK Chaitanya 8fdefb9253 merge with mainline 2010-08-26 12:11:57 +05:30
BVK Chaitanya 928bad4708 merge with mainline 2010-08-26 09:30:11 +05:30
BVK Chaitanya a9b85993ee merge with mainline 2010-08-25 14:45:56 +05:30
BVK Chaitanya 16c7cb32c8 merge with mainline 2010-08-19 16:54:00 +05:30