mirror of
https://github.com/dgibson/dtc.git
synced 2026-05-12 11:43:04 -04:00
Some checks failed
Build test / build-make (alpine) (push) Has been cancelled
Build test / build-make (archlinux) (push) Has been cancelled
Build test / build-make (fedora) (push) Has been cancelled
Build test / build-make (ubuntu) (push) Has been cancelled
Build test / build-meson (alpine) (push) Has been cancelled
Build test / build-meson (archlinux) (push) Has been cancelled
Build test / build-meson (fedora) (push) Has been cancelled
Build test / build-meson (ubuntu) (push) Has been cancelled
Build test / clang64 (push) Has been cancelled
Build test / mingw32 (push) Has been cancelled
Build test / mingw64 (push) Has been cancelled
Build test / ucrt64 (push) Has been cancelled
fdt_num_mem_rsv() can return an error if the memory reservation block is not properly terminated with a (0, 0) entry. However several other places in libfdt called it without checking for error returns, and could therefore return strange results, or in the case of fdt_open_into() crash. Fix this by always checking the return value. Add some addition tests to catch this bug. Reported-by: Moshe Strauss <moshestrauss10@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
61 lines
2 KiB
C
61 lines
2 KiB
C
#ifdef __ASSEMBLER__
|
|
#define ASM_CONST_LL(x) (x)
|
|
#else
|
|
#define ASM_CONST_LL(x) (x##ULL)
|
|
#endif
|
|
|
|
#define TEST_ADDR_1H ASM_CONST_LL(0xdeadbeef)
|
|
#define TEST_ADDR_1L ASM_CONST_LL(0x00000000)
|
|
#define TEST_ADDR_1 ((TEST_ADDR_1H << 32) | TEST_ADDR_1L)
|
|
#define TEST_SIZE_1H ASM_CONST_LL(0x00000000)
|
|
#define TEST_SIZE_1L ASM_CONST_LL(0x00100000)
|
|
#define TEST_SIZE_1 ((TEST_SIZE_1H << 32) | TEST_SIZE_1L)
|
|
#define TEST_ADDR_2H ASM_CONST_LL(0)
|
|
#define TEST_ADDR_2L ASM_CONST_LL(123456789)
|
|
#define TEST_ADDR_2 ((TEST_ADDR_2H << 32) | TEST_ADDR_2L)
|
|
#define TEST_SIZE_2H ASM_CONST_LL(0)
|
|
#define TEST_SIZE_2L ASM_CONST_LL(010000)
|
|
#define TEST_SIZE_2 ((TEST_SIZE_2H << 32) | TEST_SIZE_2L)
|
|
|
|
#define TEST_VALUE_1 0xdeadbeef
|
|
#define TEST_VALUE_2 123456789
|
|
|
|
#define TEST_VALUE64_1H ASM_CONST_LL(0xdeadbeef)
|
|
#define TEST_VALUE64_1L ASM_CONST_LL(0x01abcdef)
|
|
#define TEST_VALUE64_1 ((TEST_VALUE64_1H << 32) | TEST_VALUE64_1L)
|
|
|
|
#define PHANDLE_1 0x2000
|
|
#define PHANDLE_2 0x2001
|
|
|
|
#define TEST_STRING_1 "hello world"
|
|
#define TEST_STRING_2 "nastystring: \a\b\t\n\v\f\r\\\""
|
|
#define TEST_STRING_3 "\xde\xad\xbe\xef"
|
|
|
|
#define TEST_STRING_4_PARTIAL "foobar"
|
|
#define TEST_STRING_4_RESULT "testfoobar"
|
|
|
|
#define TEST_CHAR1 '\r'
|
|
#define TEST_CHAR2 'b'
|
|
#define TEST_CHAR3 '\0'
|
|
#define TEST_CHAR4 '\''
|
|
#define TEST_CHAR5 '\xff'
|
|
|
|
#define TEST_MEMREGION_ADDR 0x12345678
|
|
#define TEST_MEMREGION_ADDR_HI 0x8765432100000000
|
|
#define TEST_MEMREGION_SIZE 0x9abcdef0
|
|
#define TEST_MEMREGION_SIZE_HI 0x0fedcba900000000
|
|
#define TEST_MEMREGION_SIZE_INC 0x1000
|
|
|
|
#ifndef __ASSEMBLER__
|
|
extern struct fdt_header test_tree1;
|
|
extern struct fdt_header truncated_property;
|
|
extern struct fdt_header bad_node_char;
|
|
extern struct fdt_header bad_node_format;
|
|
extern struct fdt_header bad_prop_char;
|
|
extern struct fdt_header ovf_size_strings;
|
|
extern struct fdt_header truncated_string;
|
|
extern struct fdt_header truncated_memrsv;
|
|
extern struct fdt_header unterminated_memrsv;
|
|
extern struct fdt_header two_roots;
|
|
extern struct fdt_header named_root;
|
|
#endif /* ! __ASSEMBLER__ */
|