Commit Graph

20 Commits

Author SHA1 Message Date
Peter Jones f725fa7cb2 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>
2020-07-29 16:55:47 +02:00
Vladimir Serbinenko 44b38e4988 grub_menu_init_page: Avoid returning 0 geometry to avoid divisions by 0. 2015-01-21 17:42:15 +01:00
Vladimir Serbinenko 5dbde526a8 Inline printf templates when possible to enable format checking. 2013-12-21 13:40:18 +01:00
Vladimir Serbinenko a28567364a Make char and string width grub_size_t rather than grub_ssize_t. 2013-10-25 23:58:24 +02:00
Vladimir 'phcoder' Serbinenko e89c2d48a9 Lift 255x255 erminal sie restriction to 65535x65535. Also change from
bitmasks to small structures of size chosen to fit in registers.
2013-10-19 23:59:32 +02:00
Vladimir 'phcoder' Serbinenko cdce14fad4 Progressively skip menu elements on small terminals rather
than crashing.
2013-05-14 08:57:18 +02:00
Vladimir 'phcoder' Serbinenko 85002bf34a Agglomerate more mallocs to speed-up gfxterm. 2013-05-04 22:23:23 +02:00
Vladimir 'phcoder' Serbinenko 44dea3f9a9 * grub-core/normal/menu_text.c (menu_clear_timeout): Clear second
line of timeout as it may contain the rest of long line.
2013-05-04 13:52:21 +02:00
Vladimir 'phcoder' Serbinenko 03f7c8c304 Fix several memory leaks. 2013-05-04 13:47:10 +02:00
Vladimir 'phcoder' Serbinenko a59a9826fd * grub-core/normal/menu_text.c (print_entry): Put an asterisk
in front of chosen entry to mark it even if highlighting is lost.
2013-04-24 15:07:24 +02:00
Vladimir 'phcoder' Serbinenko af18fdb4df * grub-core/normal/menu_text.c (grub_menu_init_page): Fix behaviour
when menu highlight color isn't set.
2013-01-27 16:12:05 +01:00
Vladimir 'phcoder' Serbinenko bc1369732f Make color variables global instead of it being per-terminal. 2013-01-21 17:53:41 +01:00
Vladimir 'phcoder' Serbinenko e1bd676b4e Fix tab and wide character handling in editor and menu.
* grub-core/normal/charset.c (grub_unicode_aglomerate_comb): Don't
	agglomerate control characters with combining marks.
	(bidi_line_wrap): Allow break on tab.
	(grub_unicode_get_comb_start): New function.
	* grub-core/normal/menu_entry.c: Restructure to handle wide characters
	and tab correctly.
	* grub-core/normal/menu_text.c (print_entry): Replace \n, \r, \b and \e
	with a space.
	* grub-core/normal/term.c (print_ucs4_terminal): New argument
	fixed_tab_size. All users updated.
	* include/grub/term.h (GRUB_TERM_TAB_WIDTH): New const.
	(grub_term_getcharwidth): Handle \t.
	* include/grub/unicode.h (grub_unicode_glyph_dup): Fix allocation
	and copy.
2012-03-27 17:07:26 +02:00
Vladimir 'phcoder' Serbinenko 805a8dccc8 * grub-core/commands/gptsync.c: Fix typographic quoting.
* grub-core/commands/ieee1275/suspend.c: Likewise.
	* grub-core/commands/parttool.c: Likewise.
	* grub-core/commands/search_wrap.c: Likewise.
	* grub-core/commands/videoinfo.c: Likewise.
	* grub-core/gfxmenu/gui_label.c: Likewise.
	* grub-core/hello/hello.c: Likewise.
	* grub-core/kern/emu/main.c: Likewise.
	* grub-core/net/net.c: Likewise.
	* grub-core/normal/menu.c: Likewise.
	* grub-core/normal/menu_text.c: Likewise.
	* grub-core/normal/misc.c: Likewise.
	* util/grub-editenv.c: Likewise.
	* util/grub-install.in: Likewise.
	* util/grub-kbdcomp.in: Likewise.
	* util/grub-mkconfig.in: Likewise.
	* util/grub-mknetdir.in: Likewise.
	* util/grub-mkrescue.in: Likewise.
	* util/grub-mkstandalone.in: Likewise.
	* util/grub-reboot.in: Likewise.
	* util/grub-set-default.in: Likewise.
	* util/grub-setup.c: Likewise.
	* util/powerpc/ieee1275/grub-mkrescue.in: Likewise.
2012-03-03 13:05:08 +01:00
Vladimir 'phcoder' Serbinenko b4a6a53310 * grub-core/normal/menu_text.c (grub_print_message_indented_real): Fix a
warning.
2012-02-27 10:31:46 +01:00
Vladimir 'phcoder' Serbinenko d43ad75467 * grub-core/normal/menu_text.c (grub_print_message_indented_real): Add
trailing newline implicitly. All users updated.
2012-02-26 17:16:05 +01:00
Vladimir 'phcoder' Serbinenko 8b8a81fa6a Dynamically count the number of lines for the lower banner.
* grub-core/normal/menu_entry.c (per_term_screen): New member
	num_entries.
	(print_down): Use num_entries.
	(update_screen): Likewise.
	(grub_menu_entry_run): Set num_entries.
	* grub-core/normal/menu_text.c (menu_viewer_data): New member
	num_entries.
	(grub_print_message_indented): Move real part to ...
	(grub_print_message_indented_real): ... here. Additional argument
	dry_run.
	(draw_border): Additional argument num_entries.
	(print_message): Additional argument dry_run.
	(print_entries): Receive menu viewer data.
	(grub_menu_init_page): New argment num_entries.
	(menu_text_set_chosen_entry): Use num_entries.
	(grub_menu_try_text): Likewise.
	* grub-core/normal/term.c (print_ucs4_terminal): New argument dry_run.
	All users updated.
	(grub_ucs4_count_lines): New function.
	* include/grub/term.h (grub_term_cursor_x): Moved from here ..
	* grub-core/normal/menu_text.c (grub_term_cursor_x): ... to here.
	* include/grub/term.h (GRUB_TERM_MESSAGE_HEIGHT): Removed.
	(grub_term_border_height): Likewise.
	(grub_term_num_entries): Likewise.
2011-04-10 13:56:23 +02:00
Vladimir 'phcoder' Serbinenko 5aaf2c18bd Merge mainline into keylayouts 2010-08-31 14:03:29 +02:00
BVK Chaitanya 297f0c2b6e merge with mainline 2010-07-13 00:43:28 +05:30
BVK Chaitanya 8c41176882 automake commit without merge history 2010-05-06 11:34:04 +05:30