Properly handle embedded nul delimited string lists
For example: reserved-names="res1\0res2\0res3"; Where \0 is an actual embedded NUL in the source instead of a string escape. To achieve this, use the len given by the lexer instead of strlen. Without this patch dtc will mangle the output and possibly hang on realloc.
This commit is contained in:
parent
f9e91a48ba
commit
5d4a8b9c4c
4 changed files with 11 additions and 1 deletions
2
data.c
2
data.c
|
@ -74,7 +74,7 @@ struct data data_copy_escape_string(const char *s, int len)
|
|||
struct data d;
|
||||
char *q;
|
||||
|
||||
d = data_grow_for(empty_data, strlen(s)+1);
|
||||
d = data_grow_for(empty_data, len + 1);
|
||||
|
||||
q = d.val;
|
||||
while (i < len) {
|
||||
|
|
BIN
tests/embedded_nul.dts
Normal file
BIN
tests/embedded_nul.dts
Normal file
Binary file not shown.
6
tests/embedded_nul_equiv.dts
Normal file
6
tests/embedded_nul_equiv.dts
Normal file
|
@ -0,0 +1,6 @@
|
|||
/dts-v1/;
|
||||
|
||||
/ {
|
||||
reserved-names = "aaaaaaaaaaaaaaaaaa\0bbbbbb\0ccccccccccccc";
|
||||
reserved-ranges = < 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 >;
|
||||
};
|
|
@ -275,6 +275,10 @@ libfdt_tests () {
|
|||
run_dtc_test -I dts -O dtb -o sourceoutput.test.dtb sourceoutput.dts
|
||||
run_dtc_test -I dts -O dtb -o sourceoutput.test.dts.test.dtb sourceoutput.test.dts
|
||||
run_test dtbs_equal_ordered sourceoutput.test.dtb sourceoutput.test.dts.test.dtb
|
||||
|
||||
run_dtc_test -I dts -O dtb -o embedded_nul.test.dtb embedded_nul.dts
|
||||
run_dtc_test -I dts -O dtb -o embedded_nul_equiv.test.dtb embedded_nul_equiv.dts
|
||||
run_test dtbs_equal_ordered embedded_nul.test.dtb embedded_nul_equiv.test.dtb
|
||||
}
|
||||
|
||||
dtc_tests () {
|
||||
|
|
Loading…
Reference in a new issue