ACPI AML decompiler w/ CFG recovery and structured pseudocode
29

Configure Feed

Select the types of activity you want to include in your feed.

tobi / test / t_bad.c
1.5 kB 48 lines
1#include "t.h" 2 3#include "p.h" 4 5static int parse_has_error(const uint8_t *b, size_t n) { 6 tobi_parse_result r; 7 (void)tobi_parse(b, n, 0, &r); 8 int has = tobi_diag_has_error(&r.diag); 9 tobi_parse_result_free(&r); 10 return has; 11} 12 13static int strict_fails(const uint8_t *b, size_t n) { 14 tobi_parse_result r; 15 int ok = tobi_parse(b, n, 1, &r); 16 int has = tobi_diag_has_error(&r.diag); 17 tobi_parse_result_free(&r); 18 return !ok && has; 19} 20 21int t_bad(void) { 22 uint8_t trunc_pkg[] = {0x14,0x20,'M','T'}; 23 T_CHECK(parse_has_error(trunc_pkg, sizeof(trunc_pkg))); 24 uint8_t invalid_pkg[] = {0x14,0x80,0x00}; 25 T_CHECK(parse_has_error(invalid_pkg, sizeof(invalid_pkg))); 26 uint8_t unterm_str[] = {0x0d,'a','b'}; 27 T_CHECK(parse_has_error(unterm_str, sizeof(unterm_str))); 28 uint8_t trunc_name[] = {0x08,'A'}; 29 T_CHECK(parse_has_error(trunc_name, sizeof(trunc_name))); 30 uint8_t bad_table[40] = {'D','S','D','T',1,0,0,0}; 31 T_CHECK(parse_has_error(bad_table, sizeof(bad_table))); 32 uint8_t bad_sum[40] = {'S','S','D','T',40,0,0,0}; 33 T_CHECK(strict_fails(bad_sum, sizeof(bad_sum))); 34 uint8_t rnd[128]; 35 for (size_t i = 0; i < sizeof(rnd); i++) { 36 rnd[i] = (uint8_t)(i * 37u + 11u); 37 } 38 tobi_parse_result r; 39 T_CHECK(tobi_parse(rnd, sizeof(rnd), 0, &r)); 40 tobi_parse_result_free(&r); 41 uint8_t deep[160]; 42 for (size_t i = 0; i < sizeof(deep); i += 2) { 43 deep[i] = 0x10; 44 deep[i + 1] = 0x7f; 45 } 46 T_CHECK(parse_has_error(deep, sizeof(deep))); 47 return 0; 48}