Summary
Replace unsafe string functions with bounds-checked alternatives throughout the codebase.
Affected Files
spinlex.c - Multiple strcpy/strcat calls (lines 209, 227, 551, 700, 701, 1095, 1149, 1200, 1236, 1324, 1329, 1841, 1976, 1981, 1986, 1990, 2016)
structs.c - sprintf/strcat on stack buffers (lines 385, 400, 404, 405, 407, 408, 467, 471, 472, 475, 476, 493, 495, 501, 502, 503)
main.c - sprintf with offset accumulation (lines 296-314)
pangen3.c - strncpy without null termination check (line 449)
tl_mem.c - strncpy issues (line 91)
Required Changes
- Replace
strcpy() with snprintf() or bounds-checked copy
- Replace
strcat() with snprintf() or strncat() with proper length
- Replace
sprintf() with snprintf() and check return values
- Ensure all
strncpy() results are null-terminated
Testing
- Run
make test after each file is updated
- Verify no regressions in example verification
Related
Summary
Replace unsafe string functions with bounds-checked alternatives throughout the codebase.
Affected Files
spinlex.c- Multiple strcpy/strcat calls (lines 209, 227, 551, 700, 701, 1095, 1149, 1200, 1236, 1324, 1329, 1841, 1976, 1981, 1986, 1990, 2016)structs.c- sprintf/strcat on stack buffers (lines 385, 400, 404, 405, 407, 408, 467, 471, 472, 475, 476, 493, 495, 501, 502, 503)main.c- sprintf with offset accumulation (lines 296-314)pangen3.c- strncpy without null termination check (line 449)tl_mem.c- strncpy issues (line 91)Required Changes
strcpy()withsnprintf()or bounds-checked copystrcat()withsnprintf()orstrncat()with proper lengthsprintf()withsnprintf()and check return valuesstrncpy()results are null-terminatedTesting
make testafter each file is updatedRelated