mirror of
https://git.proxmox.com/git/grub2
synced 2025-08-05 02:28:26 +00:00
![]() The grub_printf_fmt_check() function parses the arguments of an untrusted printf() format and an expected printf() format and then compares the arguments counts and arguments types. The arguments count in the untrusted format string must be less or equal to the arguments count in the expected format string and both arguments types must match. To do this the parse_printf_arg_fmt() helper function is extended in the following way: 1. Add a return value to report errors to the grub_printf_fmt_check(). 2. Add the fmt_check argument to enable stricter format verification: - the function expects that arguments definitions are always terminated by a supported conversion specifier. - positional parameters, "$", are not allowed, as they cannot be validated correctly with the current implementation. For example "%s%1$d" would assign the first args entry twice while leaving the second one unchanged. - Return an error if preallocated space in args is too small and allocation fails for the needed size. The grub_printf_fmt_check() should verify all arguments. So, if validation is not possible for any reason it should return an error. This also adds a case entry to handle "%%", which is the escape sequence to print "%" character. 3. Add the max_args argument to check for the maximum allowed arguments count in a printf() string. This should be set to the arguments count of the expected format. Then the parse_printf_arg_fmt() function will return an error if the arguments count is exceeded. The two additional arguments allow us to use parse_printf_arg_fmt() in printf() and grub_printf_fmt_check() calls. When parse_printf_arg_fmt() is used by grub_printf_fmt_check() the function parse user provided untrusted format string too. So, in that case it is better to be too strict than too lenient. Signed-off-by: Thomas Frauendorfer | Miray Software <tf@miray.de> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> |
||
---|---|---|
asm-tests | ||
conf | ||
docs | ||
grub-core | ||
include | ||
po | ||
tests | ||
themes/starfield | ||
unicode | ||
util | ||
.gitattributes | ||
.gitignore | ||
.travis.yml | ||
acinclude.m4 | ||
AUTHORS | ||
autogen.sh | ||
bootstrap | ||
bootstrap.conf | ||
BUGS | ||
ChangeLog-2015 | ||
config.h.in | ||
configure.ac | ||
COPYING | ||
coreboot.cfg | ||
geninit.sh | ||
gentpl.py | ||
INSTALL | ||
linguas.sh | ||
Makefile.am | ||
Makefile.util.def | ||
NEWS | ||
README | ||
THANKS | ||
TODO |
This is GRUB 2, the second version of the GRand Unified Bootloader. GRUB 2 is rewritten from scratch to make GNU GRUB cleaner, safer, more robust, more powerful, and more portable. See the file NEWS for a description of recent changes to GRUB 2. See the file INSTALL for instructions on how to build and install the GRUB 2 data and program files. Please visit the official web page of GRUB 2, for more information. The URL is <http://www.gnu.org/software/grub/grub.html>. More extensive documentation is available in the Info manual, accessible using 'info grub' after building and installing GRUB 2. There are a number of important user-visible differences from the first version of GRUB, now known as GRUB Legacy. For a summary, please see: info grub Introduction 'Changes from GRUB Legacy'