Preserve required snprintf length on truncation
All checks were successful
libakstdlib CI Build / cmake_build (push) Successful in 2m55s
libakstdlib CI Build / sanitizers (push) Successful in 2m57s
libakstdlib CI Build / coverage (push) Successful in 2m46s
libakstdlib CI Build / mutation_test (push) Successful in 18m29s

This commit is contained in:
2026-08-03 18:25:43 -04:00
parent 0620370dd9
commit acb47a0d56
7 changed files with 64 additions and 40 deletions

View File

@@ -83,10 +83,10 @@ having visited nothing.
/* before */
aksl_sprintf(&count, buf, "%s=%d", key, value);
/* after */
aksl_snprintf(buf, sizeof(buf), "%s=%d", key, value);
aksl_snprintf(&count, buf, sizeof(buf), "%s=%d", key, value);
```
Truncation is `AKERR_OUTOFBOUNDS` rather than a short success.
Truncation is `AKERR_OUTOFBOUNDS` rather than a short success, and `*count` receives the required length.
**`aksl_realpath` takes the destination's length.**