Commit graph

34 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
ca0a4f689a verifiers: File type for fine-grained signature-verification controlling
Let's provide file type info to the I/O layer. This way verifiers
framework and its users will be able to differentiate files and verify
only required ones.

This is preparatory patch.

Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
2018-11-09 13:25:31 +01:00
Andrei Borzenkov
26533fe6bc normal: fix memory leak
Found by: Coverity scan.
CID: 96641, 96670, 96667
2016-01-12 22:40:03 +03:00
Josh Triplett
46d8a2033b * grub-core/normal/term.c (grub_set_more): Use bool logic rather than
increment/decrement.
2013-11-13 02:27:11 +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
03f7c8c304 Fix several memory leaks. 2013-05-04 13:47:10 +02:00
Vladimir 'phcoder' Serbinenko
b5a2114d76 * grub-core/normal/term.c (print_ucs4_real): Fix startwidth in dry run. 2013-05-03 13:56:45 +02:00
Vladimir 'phcoder' Serbinenko
47043f959f * grub-core/normal/term.c: Few more fixes for menu entry editor
rendering.
	Reported by: Andrey Borzenkov <arvidjaar@gmail.com>
2013-04-08 14:35:26 +02:00
Vladimir 'phcoder' Serbinenko
a321606813 * grub-core/normal/term.c: Few more fixes for menu entry editor
rendering.
	Reported by: Andrey Borzenkov <arvidjaar@gmail.com>
2013-04-07 17:48:22 +02:00
Vladimir 'phcoder' Serbinenko
91bf46b188 Fix screen corruption in menu entry editor and simplify the code
flow while on it.
2013-04-03 15:19:34 +02:00
Vladimir 'phcoder' Serbinenko
cc19857a2a New commands cbmemc, lscoreboot, coreboot_boottime to inspect
coreboot tables content. Support for cbmemc.
2013-03-20 17:13:31 +01:00
Nickolai Zeldovich
e11645f434 * grub-core/normal/crypto.c (read_crypto_list): Fix incorrect
OOM check.
	* grub-core/normal/term.c (read_terminal_list): Likewise.
2013-03-07 08:41:27 +01:00
Vladimir 'phcoder' Serbinenko
19e29ee1a9 * grub-core/normal/charset.c (grub_bidi_logical_to_visual): Add
hook pass-through parameter. All users updated and unnested.
2013-03-02 11:47:59 +01:00
Vladimir 'phcoder' Serbinenko
ec5010a3eb Improve spkmomdem reliability by adding a separator between bytes. 2013-01-21 20:03:15 +01:00
Vladimir 'phcoder' Serbinenko
34f71cb866 Improve bidi handling in entry editor. 2013-01-16 13:41:16 +01:00
Vladimir 'phcoder' Serbinenko
c2a51adee8 * grub-core/normal/term.c (read_terminal_list): Terminate the terminal
name with \0.
2012-05-23 09:09:36 +02: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
9fdb2d7b11 Fix handling of leading spaces in scripts.
* grub-core/normal/cmdline.c (grub_cmdline_get): Don't strip leading
	spaces.
	* grub-core/normal/main.c (grub_file_getline): Remove all preprocessing
	other than skipping \r. All users updated.
	* tests/grub_script_echo1.in: Add space-related tests.
	* util/grub-menulst2cfg.c (main): Remove useless space skipping.
2012-03-11 14:43:18 +01:00
Vladimir 'phcoder' Serbinenko
92cd0f6e45 Move platform-dependent files from $prefix to $prefix/$platform.
* config.h.in (GRUB_TARGET_CPU): New definition.
	(GRUB_PLATFORM): Likewise.
	* configure.ac: Define GRUB_TARGET_CPU and GRUB_PLATFORM.
	* grub-core/commands/parttool.c (grub_cmd_parttool): Update dir.
	* grub-core/efiemu/main.c (grub_efiemu_autocore): Likewise.
	* grub-core/kern/dl.c (grub_dl_load): Likewise.
	* grub-core/normal/autofs.c (read_fs_list): Likewise.
	* grub-core/normal/crypto.c (read_crypto_list): Likewise.
	* grub-core/normal/dyncmd.c (read_command_list): Likewise.
	* grub-core/normal/term.c (read_terminal_list): Likewise.
	* grub-core/gettext/gettext.c (grub_mofile_open_lang): Use
	$prefix/locale.
	(grub_gettext_init_ext): Likewise.
	* grub-core/normal/main.c (GRUB_MOD_INIT): Define grub_cpu and
	grub_platform.
	* util/grub-install.in: Update directories.
	* util/grub-mknetdir.in: Likewise.
	* util/grub-mkrescue.in: Likewise.
2012-02-04 21:47:29 +01:00
Vladimir 'phcoder' Serbinenko
6e0632e28c * grub-core/commands/acpihalt.c: Gettextized.
* grub-core/commands/cacheinfo.c: Likewise.
	* grub-core/commands/cmp.c: Likewise.
	* grub-core/commands/efi/loadbios.c: Likewise.
	* grub-core/commands/gptsync.c: Likewise.
	* grub-core/commands/ieee1275/suspend.c: Likewise.
	* grub-core/commands/legacycfg.c: Likewise.
	* grub-core/commands/memrw.c: Likewise.
	* grub-core/commands/minicmd.c: Likewise.
	* grub-core/commands/parttool.c: Likewise.
	* grub-core/commands/time.c: Likewise.
	* grub-core/commands/videoinfo.c: Likewise.
	* grub-core/disk/geli.c: Likewise.
	* grub-core/disk/i386/pc/biosdisk.c: Likewise.
	* grub-core/disk/luks.c: Likewise.
	* grub-core/disk/lvm.c: Likewise.
	* grub-core/font/font_cmd.c: Likewise.
	* grub-core/fs/zfs/zfscrypt.c: Likewise.
	* grub-core/fs/zfs/zfsinfo.c: Likewise.
	* grub-core/gfxmenu/view.c: Likewise.
	* grub-core/kern/emu/hostdisk.c: Likewise.
	* grub-core/kern/emu/main.c: Likewise.
	* grub-core/kern/emu/misc.c: Likewise.
	* grub-core/kern/emu/mm.c: Likewise.
	* grub-core/kern/mips/arc/init.c: Likewise.
	* grub-core/kern/mips/loongson/init.c: Likewise.
	* grub-core/kern/partition.c: Likewise.
	* grub-core/lib/i386/halt.c: Likewise.
	* grub-core/lib/mips/arc/reboot.c: Likewise.
	* grub-core/lib/mips/loongson/reboot.c: Likewise.
	* grub-core/loader/i386/pc/chainloader.c: Likewise.
	* grub-core/loader/i386/xnu.c: Likewise.
	* grub-core/loader/multiboot.c: Likewise.
	* grub-core/net/bootp.c: Likewise.
	* grub-core/net/net.c: Likewise.
	* grub-core/normal/term.c: Likewise.
	* grub-core/partmap/bsdlabel.c: Likewise.
	* grub-core/parttool/msdospart.c: Likewise.
	* grub-core/term/gfxterm.c: Likewise.
	* grub-core/term/terminfo.c: Likewise.
	* grub-core/video/i386/pc/vbe.c: Likewise.
	* util/grub-menulst2cfg.c: Likewise.
	* util/grub-mkdevicemap.c: Likewise.
	* util/grub-mklayout.c: Likewise.
	* util/grub-mkrelpath.c: Likewise.
	* util/grub-script-check.c: Likewise.
	* util/ieee1275/grub-ofpathname.c: Likewise.
	* util/resolve.c: Likewise.
2011-11-11 21:44:56 +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
6a6f80587b * grub-core/normal/term.c (print_ucs4_terminal): Don't try to put the
word on new line if it's too long anyway. Fixes a hang.
2011-04-08 14:25:44 +02:00
Colin Watson
32570200a8 * grub-core/normal/term.c (print_more): Make \r or \n scroll one
line, and other keys scroll an entire page (previous handling was
for \r and \n to scroll a page and other keys to scroll two lines).
2010-12-18 17:37:48 +00:00
Vladimir 'phcoder' Serbinenko
e6d983ba6d * grub-core/normal/term.c (read_terminal_list): Free in a right order. 2010-09-30 21:04:09 +02:00
Vladimir 'phcoder' Serbinenko
38c259a76a Pause the execution (10s max) if any errors are displayed so the user
has a chance to see them.

	* grub-core/kern/err.c (grub_err_printed_errors): New variable.
	(grub_print_error): Increment grub_err_printed_errors.
	* grub-core/normal/menu.c (grub_menu_execute_entry): Pause the
	execution if any errors were displayed.
	(show_menu): Remove old code for pause.
	* grub-core/normal/menu_entry.c (run): Likewise.
	* grub-core/normal/term.c (grub_normal_char_counter): Removed. All
	users updated.
	(grub_normal_get_char_counter): Likewise.
	* include/grub/err.h (grub_err_printed_errors): New external variable.
	* include/grub/normal.h (grub_normal_get_char_counter): Removed.
2010-09-20 17:46:35 +02:00
Vladimir 'phcoder' Serbinenko
d547dc281c * grub-core/normal/term.c (put_glyphs_terminal): Correct sign.
(print_backlog): set backlog_ucs4 and backlog_glyphs.
	Reported by: Yves Blusseau.
2010-09-12 22:05:27 +02:00
Vladimir 'phcoder' Serbinenko
9a9de209a2 * grub-core/normal/term.c (print_more): Return to normal and not
to standard state after printing "---MORE---".
2010-08-30 01:11:12 +02:00
Vladimir 'phcoder' Serbinenko
5303b85d44 * grub-core/normal/charset.c (grub_utf8_to_ucs4_alloc): Avoid deadloop
on malloc error.
	(grub_bidi_logical_to_visual): Check that malloc succeded.
	* grub-core/normal/term.c (grub_puts_terminal): Fix fallback to dumb
	puts.
	(grub_xputs_normal): Likewise.
2010-08-29 21:57:37 +02:00
Vladimir 'phcoder' Serbinenko
902f75f645 * grub-core/normal/term.c (print_more): Fix a memory leak.
(grub_puts_terminal): Revert to dumb puts if memory allocation fails.
	(grub_xputs_normal): Likewise.
2010-08-28 15:39:34 +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
Renamed from normal/term.c (Browse further)