* Allocate buffer for bpdt header, entries and all sub-partition content. * Returns offset in data where BPDT ends. */
| 700 | * Returns offset in data where BPDT ends. |
| 701 | */ |
| 702 | static size_t alloc_bpdt_buffer(void *data, size_t size, size_t offset, |
| 703 | struct buffer *b, const char *name) |
| 704 | { |
| 705 | struct bpdt_header bpdt_header; |
| 706 | assert((offset + BPDT_HEADER_SIZE) < size); |
| 707 | bpdt_read_header((uint8_t *)data + offset, &bpdt_header, name); |
| 708 | |
| 709 | /* Buffer to read BPDT header and entries. */ |
| 710 | alloc_buffer(b, get_bpdt_size(&bpdt_header), name); |
| 711 | |
| 712 | struct bpdt *bpdt = buffer_get(b); |
| 713 | memcpy(&bpdt->h, &bpdt_header, BPDT_HEADER_SIZE); |
| 714 | |
| 715 | /* |
| 716 | * If no entries are present, maximum offset occupied is (offset + |
| 717 | * BPDT_HEADER_SIZE). |
| 718 | */ |
| 719 | if (bpdt->h.descriptor_count == 0) |
| 720 | return (offset + BPDT_HEADER_SIZE); |
| 721 | |
| 722 | /* Read all entries. */ |
| 723 | assert((offset + get_bpdt_size(&bpdt->h)) < size); |
| 724 | bpdt_read_entries((uint8_t *)data + offset + BPDT_HEADER_SIZE, bpdt, |
| 725 | name); |
| 726 | |
| 727 | /* Read all sub-partition content in subpart_buf. */ |
| 728 | return read_subpart_buf(data, size, &bpdt->e[0], |
| 729 | bpdt->h.descriptor_count); |
| 730 | } |
| 731 | |
| 732 | static void parse_sbpdt(void *data, size_t size) |
| 733 | { |
no test coverage detected