]> git.ipfire.org Git - thirdparty/ipxe.git/commit
[image] Check delimiters when parsing command-line key-value arguments 892/head
authorMichael Brown <mcb30@ipxe.org>
Mon, 13 Feb 2023 20:40:42 +0000 (20:40 +0000)
committerMichael Brown <mcb30@ipxe.org>
Tue, 14 Feb 2023 11:13:45 +0000 (11:13 +0000)
commit76a286530a8b5bdbab81c3851b851dea2da32114
treedbdd17ee66f496fa89dbf8ae0854b6031474b9ed
parent3c83843e111ece30d3dfb5143d5e6aed6164d587
[image] Check delimiters when parsing command-line key-value arguments

The Linux kernel bzImage image format and the CPIO archive constructor
will parse the image command line for certain arguments of the form
"key=value".  This parsing is currently implemented using strstr() in
a way that can cause a false positive suffix match.  For example, a
command line containing "highmem=<n>" would erroneously be treated as
containing a value for "mem=<n>".

Fix by centralising the logic used for parsing such arguments, and
including a check that the argument immediately follows a whitespace
delimiter (or is at the start of the string).

Reported-by: Filippo Giunchedi <filippo@esaurito.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/x86/image/bzimage.c
src/core/cpio.c
src/core/image.c
src/include/ipxe/image.h