| 155 | } |
| 156 | |
| 157 | bool fv_parse(struct mem_range_t fv, struct mem_range_t *var_store, |
| 158 | bool *is_auth_var_store) |
| 159 | { |
| 160 | const EFI_FIRMWARE_VOLUME_HEADER *vol_hdr = (void *)fv.start; |
| 161 | if (!check_fw_vol_hdr(vol_hdr, fv.length)) { |
| 162 | fprintf(stderr, "No valid firmware volume was found\n"); |
| 163 | return false; |
| 164 | } |
| 165 | |
| 166 | uint8_t *fw_vol_data = fv.start + vol_hdr->HeaderLength; |
| 167 | size_t volume_size = fv.length - vol_hdr->HeaderLength; |
| 168 | const VARIABLE_STORE_HEADER *var_store_hdr = (void *)fw_vol_data; |
| 169 | if (!check_var_store_hdr(var_store_hdr, volume_size, is_auth_var_store)) { |
| 170 | fprintf(stderr, "No valid variable store was found"); |
| 171 | return false; |
| 172 | } |
| 173 | |
| 174 | var_store->start = fw_vol_data + sizeof(*var_store_hdr); |
| 175 | var_store->length = volume_size - sizeof(*var_store_hdr); |
| 176 | return true; |
| 177 | } |
no test coverage detected