platform_external_dtc/libfdt
David Gibson 70166d62a2 libfdt: Safer access to strings section
fdt_string() is used to retrieve strings from a DT blob's strings section.
It's rarely used directly, but is widely used internally.

However, it doesn't do any bounds checking, which means in the case of a
corrupted blob it could access bad memory, which libfdt is supposed to
avoid.

This write a safe alternative to fdt_string, fdt_get_string().  It checks
both that the given offset is within the string section and that the string
it points to is properly \0 terminated within the section.  It also returns
the string's length as a convenience (since it needs to determine to do the
checks anyway).

fdt_string() is rewritten in terms of fdt_get_string() for compatibility.

Most of the diff here is actually testing infrastructure.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2018-06-07 11:48:20 +10:00
..
fdt.c libfdt: Make fdt_check_header() more thorough 2018-06-07 11:47:59 +10:00
fdt.h libfdt: Remove leading underscores from identifiers 2017-10-26 09:25:14 +02:00
fdt_addresses.c libfdt: Add helpers to read #address-cells and #size-cells 2014-05-12 16:01:09 +10:00
fdt_empty_tree.c Fix a few whitespace and style nits 2017-04-09 20:56:37 +10:00
fdt_overlay.c libfdt: Clean up header checking functions 2018-06-07 11:45:44 +10:00
fdt_ro.c libfdt: Safer access to strings section 2018-06-07 11:48:20 +10:00
fdt_rw.c libfdt: Clean up header checking functions 2018-06-07 11:45:44 +10:00
fdt_strerror.c libfdt: add missing errors to fdt_strerror() 2016-11-04 07:17:20 +11:00
fdt_sw.c libfdt: Improve sequential write state checking 2018-06-07 11:45:48 +10:00
fdt_wip.c libfdt: Remove leading underscores from identifiers 2017-10-26 09:25:14 +02:00
libfdt.h libfdt: Safer access to strings section 2018-06-07 11:48:20 +10:00
libfdt_env.h libfdt: Make fdt_check_header() more thorough 2018-06-07 11:47:59 +10:00
libfdt_internal.h libfdt: Clean up header checking functions 2018-06-07 11:45:44 +10:00
Makefile.libfdt libfdt: Add overlay application function 2016-10-06 19:22:41 +11:00
TODO dtc: Update TODO files 2007-12-19 08:20:26 -06:00
version.lds libfdt: Safer access to strings section 2018-06-07 11:48:20 +10:00