On Wed, Sep 26, 2018 at 02:27:08PM -0500, Rob Herring wrote: > Commit 8c59a97ce096 ("Fix missing labels when emitting dts format") > fixed label output, but broke output when there is a REF_PATH marker. > > The problem is a REF_PATH marker causes a zero length string to be > emitted. The write_propval_string() function requires a length of at > least 1 (including the terminating '\0'), but that was not being > checked. > > For the integer output, a length of 0 is valid as it is possible to have > labels inside the starting '<': > > int-prop = < start: 0x1234>; > > REF_PHANDLE is another marker that we don't explicitly handle, but it > doesn't cause a problem as it is fundamentally just an int. > > Fixes: 8c59a97ce096 ("Fix missing labels when emitting dts format") > Reported-by: Kumar Gala <kumar.gala@xxxxxxxxxx> > Cc: Grant Likely <grant.likely@xxxxxxx> > Signed-off-by: Rob Herring <robh@xxxxxxxxxx> Applied, thanks. > --- > tests/path-references.dts | 2 +- > tests/run_tests.sh | 6 ++++++ > treesource.c | 4 ++++ > 3 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/tests/path-references.dts b/tests/path-references.dts > index 8c66d8057bbd..1fb7d7045672 100644 > --- a/tests/path-references.dts > +++ b/tests/path-references.dts > @@ -16,7 +16,7 @@ > foobar { > n3: baz { > ref = &{/foo/baz}; > - lref = &n4; > + lref = start: &n4 end:; > }; > }; > foo { > diff --git a/tests/run_tests.sh b/tests/run_tests.sh > index 6756f3d9f7be..ef97dd84b46d 100755 > --- a/tests/run_tests.sh > +++ b/tests/run_tests.sh > @@ -567,6 +567,12 @@ dtc_tests () { > run_dtc_test -I dts -O dts $tree.test.dts > run_wrap_test cmp $tree $tree.test.dts > done > + for tree in path-references; do > + run_dtc_test -I dts -O dtb -o $tree.test.dtb $tree.dts > + run_dtc_test -I dts -O dts -o $tree.test.dts $tree.dts > + run_dtc_test -I dts -O dtb -o $tree.test.dts.test.dtb $tree.test.dts > + run_test dtbs_equal_ordered $tree.test.dtb $tree.test.dts.test.dtb > + done > > # Check -Oyaml output > if pkg-config --exists yaml-0.1; then > diff --git a/treesource.c b/treesource.c > index c1fdb8664921..93fd8ac1c513 100644 > --- a/treesource.c > +++ b/treesource.c > @@ -64,6 +64,10 @@ static bool isstring(char c) > static void write_propval_string(FILE *f, const char *s, size_t len) > { > const char *end = s + len - 1; > + > + if (!len) > + return; > + > assert(*end == '\0'); > > fprintf(f, "\""); -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Attachment:
signature.asc
Description: PGP signature