coreboot-kgpe-d16/util
Julius Werner ee87885343 cbfs-compression-tool: Fix minor edge cases in algorithm type parsing
This patch adds two minor improvements to the way cbfs-compression-tool
parses the compression algorithm type that is passed through the -t
option of the 'compress' subcommand. These improvements are intended
to prevent accidents and unexpected behavior when using the
cbfs-compression-tool, in particular in automated contexts such as a
Makefile rule.

In the first part of this patch, a return statement is inserted after
the 'if (algo->name == NULL)' check of the compress() function. This
causes the function to exit immediately and subsequently abort the
program when the algorithm type was not detected correctly. Previously,
execution would continue with the 'algo' pointer pointing to the zeroed
out stopper entry of the types_cbfs_compression[] array. The ultimate
effect of this would be to pass 0 as 'algo->type' to the
compression_function() function, which happens to be the same
enumeration value as is used for CBFS_COMPRESS_NONE, leading to a valid
compression function result that matches the behavior of no compression.
Thus, if a script calling cbfs-compression-tool compress contained a
typo in the -t parameter, it would continue running with an unintended
compression result rather than immediately exiting cleanly.

In the second part of this patch, the strcmp() function is replaced with
strcasecmp() when comparing 'algo->name' with the 'algoname' parameter
that was passed to the compress() function. strcasecmp() uses an
identical function signature as strcmp() and is thus suitable as a
drop-in replacement, but it differs in behavior: rather than only
returning a result of 0 when the two NULL-terminated input strings are
character by character identical, the strcasecmp() function applies a
weaker concept of identity where characters of the latin alphabet
(hexadecimal ranges 0x41 through 0x5a and 0x61 through 0x7a) are also
considered identical to other characters that differ from them only in
their case. This causes the -t parameter of cbfs-compression-tool
compress to also accept lowercase spellings of the available compression
algorithms, such as "lz4" instead of "LZ4" and "lzma" instead of "LZMA".
As an unintended but harmless side-effect, mixed-case spellings such as
"lZ4" or "LZmA" will also be recognized as valid compression algorithms.
(Note that since the character "4" (hexadecimal 0x34) of the "LZ4"
compression type name is not part of the above-mentioned ranges of latin
alphabet characters, no new substitutions become valid for that part of
the "LZ4" string with this patch.)

Change-Id: I375dbaeefaa0d4b0c5be81bf7668f8f330f1cf61
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/26389
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
2018-05-21 13:25:49 +00:00
..
abuild util/abuild: Disable unspecified payload options 2018-05-17 12:06:33 +00:00
acpi
amdfwtool util/amdfwtool/amdfwtool.c: Check fstat return 2018-02-22 09:59:40 +00:00
amdtools
archive
arm_boot_tools/mksunxiboot
autoport util/autoport: Improve `readme.me` 2018-04-29 16:46:04 +00:00
bimgtool
bincfg util/bincfg: don't use fp shared variable 2018-01-23 05:21:48 +00:00
board_status board_status: Remove sudo when checking for cbmem with command 2018-05-03 15:07:34 +00:00
broadcom util/broadcom/secimage: Add distclean target 2018-02-10 23:49:58 +00:00
cbfstool cbfs-compression-tool: Fix minor edge cases in algorithm type parsing 2018-05-21 13:25:49 +00:00
cbmem util/cbmem: Fix compare function for qsort 2018-05-18 20:13:47 +00:00
checklist
chromeos
crossgcc buildgcc: Add missing '\' 2018-04-28 07:16:58 +00:00
docker util/docker: Update coreboot-sdk dockerfile dependencies list 2018-05-21 13:21:39 +00:00
dtd_parser
ectool ectool: Add an option to get and use EC ports from /proc/ioports 2018-04-19 16:30:23 +00:00
exynos
futility
fuzz-tests
genbuild_h util/genbuild_h: Add gitfile support 2018-01-23 05:33:02 +00:00
genprof
gitconfig util/gitconfig: Replace printf with heredoc 2018-01-23 05:22:40 +00:00
ifdfake
ifdtool ifdtool: Add a list of known platforms that support IFD_VERSION_2 2018-05-04 01:15:52 +00:00
intelmetool util/intelmetool: Be explicit about *kernel* cmdline arguments 2018-04-28 15:28:52 +00:00
inteltool inteltool: Add some Skylake desktop ids 2018-03-27 15:42:14 +00:00
intelvbttool
ipqheader util/*: Fix final newlines in scripts 2018-01-23 05:17:44 +00:00
k8resdump
kbc1126
kconfig
lint util/lint: Ignore whitespace, newlines, and licenses in vbt files 2018-05-09 16:19:36 +00:00
marvell
me_cleaner util/me_cleaner: Update to v1.2 2018-04-06 06:54:14 +00:00
mma
msrtool msrtool: add VIA C7 2018-05-15 11:14:10 +00:00
mtkheader
nvidia
nvramtool cbfs: Rename CBFS_TYPE_PAYLOAD to CBFS_TYPE_SELF 2018-05-04 10:30:24 +00:00
optionlist
post
qualcomm/scripts/cmm util/qualcomm: Add T32 debug scripts 2018-04-27 09:21:11 +00:00
release util/release/genrelnotes: Add "sifive" search pattern 2018-05-05 15:24:45 +00:00
riscv src/sifive: Add the SiFive Freedom Unleashed 540 SoC 2018-04-26 11:52:37 +00:00
rockchip
romcc
sconfig devicetree: Add USB device type 2018-05-11 08:59:51 +00:00
scripts util/scripts: Add script to alphabetize MAINTAINERS file 2018-04-16 22:25:31 +00:00
showdevicetree sconfig: Add a new mmio resource type 2018-01-25 16:50:17 +00:00
spkmodem_recv
superiotool Use git HTTP URLs without `/p` in it 2018-04-17 10:38:06 +00:00
testing util/testing: Update junit.xml to support coreboot builds 2018-05-21 13:17:38 +00:00
uio_usbdebug
vgabios
viatool
x86 util/x86/x86_page_tables: add command line to generated files 2018-04-27 03:25:28 +00:00
xcompile util/xcompile: prefer riscv64 over riscv 2018-05-09 10:00:32 +00:00