mirror of
https://github.com/rsyslog/rsyslog.git
synced 2026-06-15 23:22:50 +02:00
Why: Older platforms need consistent formatted string allocation, and the remaining copy helpers kept triggering review noise around classic C string APIs. A major motivation is to avoid very common AI review false positives: those tools often do not understand the actual scope and safety checks, and then mechanically flag strcpy-style APIs despite the surrounding bounds and initialization logic being correct. Impact: string allocation and bounded copy paths are now explicit and portable across the tree. Before/After: ad hoc unsafe string helpers remained; now allocation and bounded copies follow one portable pattern. Technical Overview: Add a complete asprintf and vasprintf compatibility layer with shared prototypes so older libc variants build without local wrappers. Replace repo-wide strcpy, strcat, strncat, sprintf, and direct strncpy uses with explicit memcpy-based bounded copies or exact-width byte copies as appropriate for each destination. Add rsCStrAppendParts() for incremental string assembly so callers can build pre-sized buffers without repeated snprintf return handling. Update the unicode helper copy routine so existing ustrncpy() call sites no longer route to libc strncpy semantics. This also removes a broad class of review distractions from automated AI reviewers that key off banned function names without understanding the actual copy contract at the call site. Extend the stringbuf unit coverage for the new append helper and the formatted-allocation compatibility path. With the help of AI-Agents: Codex