The full verified blob of one ledger file into the model. */
| 266 | |
| 267 | /* The full verified blob of one ledger file into the model. */ |
| 268 | static bool reg_add(cni_context *c, cni_reader *reader, cls_budget_t *budget, |
| 269 | cbm_test_model_t *model, const cbm_test_impact_classified_t *row) { |
| 270 | const cbm_inventory_file_t *file = &reader->files[row->file_index]; |
| 271 | if (budget->reads == 0 || file->content_length > budget->content_bytes || |
| 272 | file->content_length > (uint64_t)SIZE_MAX) { |
| 273 | return cls_fail(c, CBM_INVENTORY_LIMIT, "test registry exceeds the read budget"); |
| 274 | } |
| 275 | size_t len = (size_t)file->content_length; |
| 276 | char *text = cbm_alloc(CBM_MEM_CLASS_EXTRACT, len ? len : 1); |
| 277 | if (!text) { |
| 278 | return cls_fail(c, CBM_INVENTORY_OOM, "test registry source allocation failed"); |
| 279 | } |
| 280 | size_t copied = 0; |
| 281 | reader->content_bound = budget->content_bytes; |
| 282 | cbm_inventory_error_t read_error; |
| 283 | bool ok = cni_read(reader, row->file_index, (unsigned char *)text, len, &copied, c->control, |
| 284 | &read_error) == CBM_INVENTORY_OK; |
| 285 | if (ok && copied != len) { |
| 286 | ok = cls_fail(c, CBM_INVENTORY_CHANGED, "test registry source length changed"); |
| 287 | } |
| 288 | if (ok) { |
| 289 | budget->reads--; |
| 290 | budget->content_bytes -= file->content_length; |
| 291 | if (!cbm_test_model_add_source_language(model, (const char *)file->path.data, |
| 292 | cbm_language_name(row->language), text, len)) { |
| 293 | ok = cls_fail(c, CBM_INVENTORY_OOM, "test registry source was not accepted"); |
| 294 | } |
| 295 | } |
| 296 | cbm_free(CBM_MEM_CLASS_EXTRACT, text); |
| 297 | return ok; |
| 298 | } |
| 299 | |
| 300 | cbm_inventory_status_t cbm_test_impact_registry( |
| 301 | const cbm_test_impact_ledger_t *ledger, const cbm_test_impact_inventory_t *inventory, |
no test coverage detected