summaryrefslogtreecommitdiff
path: root/tests/dumptrees.c
Commit message (Collapse)AuthorAgeFilesLines
* tests: Fix signedness comparisons warningsAndre Przywara2021-06-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With -Wsign-compare, compilers warn about a mismatching signedness in comparisons in various files in the tests/ directory. For about half of the cases we can simply change the signed variable to be of an unsigned type, because they will never need to store negative values (which is the best fix of the problem). In the remaining cases we can cast the signed variable to an unsigned type, provided we know for sure it is not negative. We see two different scenarios here: - We either just explicitly checked for this variable to be positive (if (rc < 0) FAIL();), or - We rely on a function returning only positive values in the "length" pointer if the function returned successfully: which we just checked. At two occassions we compare with a constant "-1" (even though the variable is unsigned), so we just change this to ~0U to create an unsigned comparison value. Since this is about the tests, let's also add explicit tests for those values really not being negative. This fixes "make tests" (but not "make check" yet), when compiled with -Wsign-compare. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20210618172030.9684-2-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: Check that the root-node name is emptySimon Glass2021-03-231-1/+2
| | | | | | | | | | | | | | | | The root node is supposed to have an empty name, but at present this is not checked. The behaviour of such a tree is not well defined. Most software rightly assumes that the root node is at offset 0 and does not check the name. This oddity was discovered as part of a security investigation into U-Boot verified boot. Add a check for this to fdt_check_full(). Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Arie Haenel <arie.haenel@intel.com> Reported-by: Julien Lenoir <julien.lenoir@intel.com> Message-Id: <20210323010410.3222701-2-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: Check that there is only one root nodeSimon Glass2021-03-231-0/+1
| | | | | | | | | | | | | | | At present it is possible to have two root nodes and even access nodes in the 'second' root. Such trees should not be considered valid. This was discovered as part of a security investigation into U-Boot verified boot. Add a check for this to fdt_check_full(). Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Arie Haenel <arie.haenel@intel.com> Reported-by: Julien Lenoir <julien.lenoir@intel.com> Message-Id: <20210323000926.3210733-1-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dumptrees: pass outputdir as first argumentMarc-André Lureau2019-10-141-0/+10
| | | | | | | | | Instead of outputing files to current directory, allow to specificy an output directory. This helps with meson build system out-of-tree support. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20191009102025.10179-4-marcandre.lureau@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* tests: Replace license boilerplate with SPDX tagsRob Herring2019-06-211-16/+1
| | | | | | | | | Replace instances in tests of mostly LGPL-2.1 license boilerplate with SPDX tags. Signed-off-by: Rob Herring <robh@kernel.org> Message-Id: <20190620211944.9378-5-robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: Add fdt_check_full() functionDavid Gibson2018-06-071-0/+2
| | | | | | | | | | | | | This new function implements a complete and thorough check of an fdt blob's structure. Given a buffer containing an fdt, it should return 0 only if the fdt within is structurally sound in all regards. It doesn't check anything about the blob's contents (i.e. the actual values of the nodes and properties), of course. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: Simon Glass <sjg@chromium.org>
* Remove leading underscores from identifiersDavid Gibson2017-10-261-1/+1
| | | | | | | | | | | | | | In a number of places, dtc and associated tools and test code use leading _ characters on identifiers to flag them as "internal", an idiom taken from the Linux kernel. This is a bad idea in a userspace program, because identifiers with a leading _ are reserved for the C library / system. In some cases, the extra _ served no real purpose, so simply drop it. In others move to the end of the identifier, which is a convention we're free to use for our own purposes. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Fix assorted sparse warningsDavid Gibson2017-03-061-1/+1
| | | | | | | | | | | | | | | | | This fixes a great many sparse warnings on the fdt and libfdt sources. These are mostly due to incorrect mixing of endian annotated and native integer types. This includes fixing a couple of quasi-bugs where we had endian conversions the wrong way around (this will have the right effect in practice, but is certainly conceptually incorrect). This doesn't make the whole tree sparse clean: there are many warnings in bison and lex generated code, and there are a handful of other remaining warnings that are (for now) more trouble than they're worth to fix (and are not genuine bugs). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Catch unsigned 32bit overflow when parsing flattened device tree offsetsAnton Blanchard2016-02-191-0/+1
| | | | | | | | | | | | | | | | We have a couple of checks of the form: if (offset+size > totalsize) die(); We need to check that offset+size doesn't overflow, otherwise the check will pass, and we may access past totalsize. Found with AFL. Signed-off-by: Anton Blanchard <anton@samba.org> [Added a testcase] Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc/tests: don't include fdt.h prior to libfdt.hKim Phillips2013-01-061-2/+0
| | | | | | | | | tests will need fdt type definitions provided in a subsequent patch to libfdt_env.h. Since libfdt.h includes libfdt_env.h in the right order anyway, just remove the fdt.h include. Signed-off-by: Kim Phillips <kim.phillips@freescale.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Implement checks for the format of node and property namesDavid Gibson2008-03-231-0/+1
| | | | | | | | | | | | | | | | This patch adds checks to the checking framework to verify that node and property names contain only legal characters, and in the case of node names there is at most one '@'. At present when coming from dts input, this is mostly already ensured by the grammer, however putting the check later means its easier to generate helpful error messages rather than just "syntax error". For dtb input, these checks replace the older similar check built into flattree.c. Testcases for the checks are also implemented. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Add missing copyright notice for dumptrees.cDavid Gibson2007-12-191-0/+21
| | | | | | | | | | | When I released libfdt, I forgot to add a copyright notice to dumptrees.c (probably because the program is so trivial). Apparently the lack causes trouble for Debian, so this patch adds one. I've gone through the git history and double checked that no-one has touched this file except me (and I barely have myself since its initial commit). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Merge libfdt into dtc.David Gibson2007-06-141-0/+49
Having pulled the libfdt repository into dtc, merge the makefiles and testsuites so that they build together usefully.