| 1688 | } |
| 1689 | |
| 1690 | static bool gf_batch_payload(cbm_git_facts_t *facts, cbm_git_bytes_t capture, size_t *offset, |
| 1691 | size_t size, cbm_git_bytes_t *bytes, cbm_git_facts_error_t *error) { |
| 1692 | if (size >= capture.length - *offset) |
| 1693 | return gf_error(error, CBM_GIT_FACTS_COMMAND, "Truncated Git batch payload"); |
| 1694 | size_t start = *offset; |
| 1695 | for (size_t left = size; left;) { |
| 1696 | if (!gf_batch_gate(facts, error)) |
| 1697 | return false; |
| 1698 | size_t chunk = left > 65536 ? 65536 : left; |
| 1699 | *offset += chunk; |
| 1700 | left -= chunk; |
| 1701 | } |
| 1702 | if (!gf_batch_gate(facts, error)) |
| 1703 | return false; |
| 1704 | if (capture.data[*offset] != '\n') |
| 1705 | return gf_error(error, CBM_GIT_FACTS_COMMAND, "Malformed Git batch payload separator"); |
| 1706 | (*offset)++; |
| 1707 | *bytes = (cbm_git_bytes_t){capture.data + start, size}; |
| 1708 | return true; |
| 1709 | } |
| 1710 | |
| 1711 | /* One exact capture driver for production and deterministic parser tests. */ |
| 1712 | static bool gf_batch_capture(cbm_git_facts_t *facts, cbm_git_bytes_t capture, |
no test coverage detected