dtc/libfdt
David Gibson 812b1956a0 libfdt: Tweak data handling to satisfy Coverity
In libfdt we often sanity test fdt_totalsize(fdt) fairly early, then
trust it (but *only* that header field) for the remainder of our work.
However, Coverity gets confused by this - it sees the byteswap in
fdt32_ld() and assumes that means it is coming from an untrusted source
everytime, resulting in many tainted data warnings.

Most of these end up with logic in fdt_get_string() as the unsafe
destination for this tainted data, so let's tweak the logic there to make
it clearer to Coverity that this is ok.

We add a sanity test on fdt_totalsize() to fdt_probe_ro_().  Because the
interface allows bare ints to be used for offsets, we already have the
assumption that totalsize must be 31-bits or less (2GiB would be a
ludicrously large fdt).  This makes this more explicit.

We also make fdt_probe_ro() return the size for convenience, and change the
logic in fdt_get_string() to keep it in a local so that Coverity can see
that it has already been bounds-checked.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-07-05 15:31:12 +10:00
..
.gitignore Link tools and tests against libfdt shared library 2019-03-29 17:20:16 +11:00
fdt.c libfdt: Tweak data handling to satisfy Coverity 2019-07-05 15:31:12 +10:00
fdt.h libfdt: Replace GPL/BSD boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
fdt_addresses.c libfdt: Replace GPL/BSD boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
fdt_empty_tree.c libfdt: Replace GPL/BSD boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
fdt_overlay.c fdtoverlay: Ignore symbols in overlays which don't apply to the target tree 2019-07-04 15:10:01 +10:00
fdt_ro.c libfdt: Tweak data handling to satisfy Coverity 2019-07-05 15:31:12 +10:00
fdt_rw.c libfdt: Replace GPL/BSD boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
fdt_strerror.c libfdt: Replace GPL/BSD boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
fdt_sw.c libfdt: Replace GPL/BSD boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
fdt_wip.c libfdt: Replace GPL/BSD boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
libfdt.h libfdt: Replace GPL/BSD boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
libfdt_env.h libfdt: Replace GPL/BSD boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
libfdt_internal.h libfdt: Tweak data handling to satisfy Coverity 2019-07-05 15:31:12 +10:00
Makefile.libfdt libfdt: Add dual GPL/BSD SPDX tags to files missing license text 2019-06-21 21:06:10 +10:00
TODO dtc: Update TODO files 2007-12-19 08:20:26 -06:00
version.lds libfdt: Add dual GPL/BSD SPDX tags to files missing license text 2019-06-21 21:06:10 +10:00