On 11 April 2018 at 22:52, David Gibson <david@xxxxxxxxxxxxxxxxxxxxx> wrote: > Currently fdt_check_header() performs only some rudimentary checks, which > is not really what the name suggests. This strengthens fdt_check_header() > to check as much about the blob as is possible from the header alone: as > well as checking the magic number and version, it checks that the total > size is sane, and that all the sub-blocks within the blob lie within the > total size. > > * This broadens the meaning of FDT_ERR_TRUNCATED to cover all sorts of > improperly terminated blocks as well as just a structure block without > FDT_END. > > * This makes fdt_check_header() only succeed on "complete" blobs, not > in-progress sequential write blobs. The only reason this didn't fail > before was that this function used to be called by many RO functions > which are supposed to also work on incomplete SW blobs. > > Signed-off-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx> > --- > libfdt/fdt.c | 57 ++++++++++++++++++++++- > libfdt/libfdt.h | 5 +- > libfdt/libfdt_env.h | 1 + > tests/.gitignore | 1 + > tests/Makefile.tests | 2 +- > tests/check_header.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++ > tests/run_tests.sh | 2 + > 7 files changed, 192 insertions(+), 4 deletions(-) > create mode 100644 tests/check_header.c > Reviewed-by: Simon Glass <sjg@xxxxxxxxxxxx> Seems like a clever way to do these tests without too much code. -- To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html