Commit Graph

6 Commits

Author SHA1 Message Date
Richard Hughes
eb30233b35 Improve FDT parsing compatibility
Newer versions of dtc agressively pack the string table, using *any* matching
suffix rather than whole strings. This is specification compliant, but breaks
if you use the offset as a hash key as a [premature] optimization.

Just use the string table as a flat block of memory rather than pre-parsing it.

This fixes reading the system FDT on new OpenBMC builds.
2023-01-18 07:59:45 +00:00
Richard Hughes
84a27ea8b9 Fix a fuzzing crash when parsing malicious FDT data 2022-09-12 13:48:45 +01:00
Richard Hughes
0c51630991 Check firmware magic in a more standard way
Some parsers are ignoring the magic when using _FLAG_IGNORE_CHECKSUM
(which is wrong; fuzzers have no problem with enforcing a static prefix)
and other either disregard the offset or check the magic in an unsafe
way. Also, use FWUPD_ERROR_INVALID_FILE consistently for magic failure.

Add a vfunc, and move all the clever code into one place.
2022-07-14 14:48:15 +01:00
Richard Hughes
56e5c1b7a9 Fix critical warning when parsing invalid FDT firmware
Never let firmware_current be NULL by checking for the root node ENDing.

Fixes https://oss-fuzz.com/testcase-detail/5454411320655872
2022-07-13 22:04:01 +01:00
Richard Hughes
3b71918346 trivial: Remove some dead code spotted by Coverity 2022-07-11 10:17:59 +01:00
Richard Hughes
f3755ef708 Add support for Flattened Devicetree aka FDT firmware 2022-07-08 14:05:20 +01:00