Summary
Critical config and DB-loaded values are parsed with atoi/atof/atoll, which silently convert invalid input to 0 and do not provide range/error visibility.
Why this matters
- Invalid numeric strings can silently become operational values.
- Can unintentionally set ports/timeouts/retries/thread counts to unsafe defaults.
- Overflow/underflow behavior is not handled explicitly.
Evidence
poller.c parses many host fields via atoi/atof/atoll.
util.c config parsing and runtime settings also use silent conversion.
- Current code usually checks for NULL input but not conversion validity.
Scope
- Introduce validated parse helpers (
strtol/strtoul/strtod + errno + endptr checks).
- Add range bounds per field (for example port, timeout, retries, thread limits).
- Standardize failure behavior (log + safe fallback or skip item) per field criticality.
Proposed implementation
- Add shared parsing helpers in
util.c/util.h (or a dedicated parse module).
- Migrate high-impact call sites first:
- host loading in
poller.c
- config/runtime option parsing in
util.c
- CLI integer parsing in
spine.c where applicable
- Emit structured warnings for invalid values with field name + source.
- Add bounds checks and explicit clamps/rejections.
Acceptance Criteria
- No critical path relies on raw
atoi/atof/atoll conversions.
- Invalid numeric inputs are detectable in logs and do not silently become 0.
- Field ranges are enforced consistently.
- Existing valid configs continue to behave unchanged.
Out of scope
- Refactoring unrelated parsing logic.
- Broad configuration format redesign.
Summary
Critical config and DB-loaded values are parsed with
atoi/atof/atoll, which silently convert invalid input to0and do not provide range/error visibility.Why this matters
Evidence
poller.cparses many host fields viaatoi/atof/atoll.util.cconfig parsing and runtime settings also use silent conversion.Scope
strtol/strtoul/strtod+errno+ endptr checks).Proposed implementation
util.c/util.h(or a dedicated parse module).poller.cutil.cspine.cwhere applicableAcceptance Criteria
atoi/atof/atollconversions.Out of scope