From d728ad59f53e72be21fe9bc419953c94aea798cc Mon Sep 17 00:00:00 2001 From: David Gibson Date: Sun, 3 Jan 2016 23:01:24 +1100 Subject: [PATCH] Fix crash on nul character in string escape sequence If a dts file contains a string with \ followed by a nul byte - an actual nul in the input file, not the \\0 escape - then the assert() in get_escape_char() will trip, crashing dtc. As far as I can tell, there isn't any valid need for this assert(), so just remove it. Reported-by: Anton Blanchard Signed-off-by: David Gibson --- tests/nul-in-escape.dts | Bin 0 -> 36 bytes tests/run_tests.sh | 1 + util.c | 1 - 3 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 tests/nul-in-escape.dts diff --git a/tests/nul-in-escape.dts b/tests/nul-in-escape.dts new file mode 100644 index 0000000000000000000000000000000000000000..9bed351cf021b252cd5e72fe6ade6c14b697c0e7 GIT binary patch literal 36 lcmdN-DJj-1Gt{@{;?h^B=2C!y3I$sQr5FY!Ypz;rE&!6l2R#4) literal 0 HcmV?d00001 diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 7bdf8e0..b40ba9c 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -292,6 +292,7 @@ libfdt_tests () { run_wrap_error_test $DTC division-by-zero.dts run_wrap_error_test $DTC bad-octal-literal.dts + run_dtc_test -I dts -O dtb nul-in-escape.dts } dtc_tests () { diff --git a/util.c b/util.c index cbb945b..fb124ee 100644 --- a/util.c +++ b/util.c @@ -152,7 +152,6 @@ char get_escape_char(const char *s, int *i) int j = *i + 1; char val; - assert(c); switch (c) { case 'a': val = '\a';