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
Andrei Borzenkov
609c049dcc
kernel: print and reset grub_errno after each embedded config line
...
Otherwise it causes subsequent file open to fail, because grub_file_open
misinterprets set grub_errno for grub_file_get_device_name failure.
Closes: 46540
2015-12-16 21:20:30 +03:00
Vladimir Serbinenko
ac319fbc90
* grub-core/kern/parser.c (grub_parser_split_cmdline): Remove nested
...
function.
2013-11-07 02:53:43 +01:00
Colin Watson
09fd6d8293
Remove nested functions from script reading and parsing.
...
* grub-core/kern/parser.c (grub_parser_split_cmdline): Add
getline_data argument, passed to getline.
* grub-core/kern/rescue_parser.c (grub_rescue_parse_line): Add
getline_data argument, passed to grub_parser_split_cmdline.
* grub-core/script/lexer.c (grub_script_lexer_yywrap): Pass
lexerstate->getline_data to lexerstate->getline.
(grub_script_lexer_init): Add getline_data argument, saved in
lexerstate->getline_data.
* grub-core/script/main.c (grub_normal_parse_line): Add getline_data
argument, passed to grub_script_parse.
* grub-core/script/script.c (grub_script_parse): Add getline_data
argument, passed to grub_script_lexer_init.
* include/grub/parser.h (grub_parser_split_cmdline): Update
prototype. Update all callers to pass appropriate getline data.
(struct grub_parser.parse_line): Likewise.
(grub_rescue_parse_line): Likewise.
* include/grub/reader.h (grub_reader_getline_t): Add void *
argument.
* include/grub/script_sh.h (struct grub_lexer_param): Add
getline_data member.
(grub_script_parse): Update prototype. Update all callers to pass
appropriate getline data.
(grub_script_lexer_init): Likewise.
(grub_normal_parse_line): Likewise.
* grub-core/commands/legacycfg.c (legacy_file_getline): Add unused
data argument.
* grub-core/kern/parser.c (grub_parser_execute: getline): Make
static instead of nested. Rename to ...
(grub_parser_execute_getline): ... this.
* grub-core/kern/rescue_reader.c (grub_rescue_read_line): Add unused
data argument.
* grub-core/normal/main.c (read_config_file: getline): Make static
instead of nested. Rename to ...
(read_config_file_getline): ... this.
(grub_normal_read_line): Add unused data argument.
* grub-core/script/execute.c (grub_script_execute_sourcecode:
getline): Make static instead of nested. Rename to ...
(grub_script_execute_sourcecode_getline): ... this.
* util/grub-script-check.c (main: get_config_line): Make static
instead of nested.
2013-01-15 12:03:25 +00:00
Colin Watson
5c67ea6cd9
Remove several trivially-unnecessary uses of nested functions.
...
* grub-core/commands/i386/pc/sendkey.c
(grub_cmd_sendkey: find_key_code, find_ascii_code): Make static
instead of nested.
* grub-core/commands/legacycfg.c (legacy_file: getline): Likewise.
Rename to ...
(legacy_file_getline): ... this.
* grub-core/commands/loadenv.c (grub_cmd_load_env: set_var):
Likewise.
* grub-core/kern/corecmd.c (grub_core_cmd_set: print_env): Likewise.
* grub-core/kern/fs.c (grub_fs_probe: dummy_func): Likewise. Rename
to ...
(probe_dummy_iter): ... this.
* grub-core/kern/i386/coreboot/mmap.c
(grub_linuxbios_table_iterate: check_signature): Likewise.
* grub-core/kern/parser.c (grub_parser_split_cmdline:
check_varstate): Likewise. Mark inline.
* grub-core/lib/arg.c (find_short: fnd_short): Likewise. Pass
an additional parameter.
(find_long: fnd_long): Likewise. Pass two additional parameters.
* grub-core/lib/crc.c (init_crc32c_table: reflect): Likewise.
* grub-core/lib/crc64.c (init_crc64_table: reflect): Likewise.
* grub-core/lib/ieee1275/cmos.c (grub_cmos_find_port: hook):
Likewise. Rename to ...
(grub_cmos_find_port_iter): ... this.
* grub-core/lib/ieee1275/datetime.c (find_rtc: hook): Likewise.
Rename to ...
(find_rtc_iter): ... this.
* grub-core/normal/menu_entry.c (run): Fold nested editor_getsource
function directly into the function body, since it is only called
once.
2012-12-31 17:31:38 +00:00
Vladimir 'phcoder' Serbinenko
6d8db94786
* grub-core/kern/parser.c (grub_parser_state_transitions): Handle \t.
...
(grub_parser_cmdline_state): Likewise.
(grub_parser_split_cmdline): Likewise.
2012-06-02 14:39:35 +02: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
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