Commit graph

8 commits

Author SHA1 Message Date
David Gibson
4b8fcc3d01 libfdt: Add fdt_check_full() function
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>
2018-06-07 11:49:17 +10:00
David Gibson
3b62fdaebf Remove leading underscores from identifiers
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>
2017-10-26 09:25:14 +02:00
David Gibson
bad5b28049 Fix assorted sparse warnings
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>
2017-03-06 12:08:53 +11:00
Anton Blanchard
2e53f9d2f0 Catch unsigned 32bit overflow when parsing flattened device tree offsets
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>
2016-02-19 01:08:46 +11:00
Kim Phillips
38ad79d339 dtc/tests: don't include fdt.h prior to libfdt.h
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>
2013-01-06 15:48:51 -06:00
David Gibson
fa5b520ccb dtc: Implement checks for the format of node and property names
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>
2008-03-23 08:00:32 -05:00
David Gibson
08c0be206d dtc: Add missing copyright notice for dumptrees.c
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>
2007-12-19 08:18:08 -06:00
David Gibson
12578976fe Merge libfdt into dtc.
Having pulled the libfdt repository into dtc, merge the makefiles and
testsuites so that they build together usefully.
2007-06-14 15:05:55 +10:00
Renamed from libfdt/tests/dumptrees.c (Browse further)