| 8 | #include <stdlib.h> |
| 9 | |
| 10 | long cbm_max_file_bytes(void) { |
| 11 | /* 512 MiB — generous: real source files never approach it, but a |
| 12 | * pathological / vendored blob degrades to a reported "oversized" skip |
| 13 | * instead of a silent drop or an unbounded read. */ |
| 14 | const long default_cap = 512L * 1024 * 1024; |
| 15 | |
| 16 | const char *raw = getenv("CBM_MAX_FILE_BYTES"); |
| 17 | if (raw && raw[0]) { |
| 18 | errno = 0; |
| 19 | char *end = NULL; |
| 20 | long v = strtol(raw, &end, 10); |
| 21 | if (errno == 0 && end != raw && *end == '\0' && v > 0) { |
| 22 | return v; |
| 23 | } |
| 24 | /* Unparseable / non-positive → fall through to the safe default. */ |
| 25 | } |
| 26 | return default_cap; |
| 27 | } |
| 28 | |
| 29 | /* Shared env-int parser: a positive integer in [1, INT_MAX], else the fallback. |
| 30 | * Read fresh each call (see cbm_max_file_bytes rationale — cheap, test-friendly, |
no outgoing calls
no test coverage detected