safe-c-functions

Installation
SKILL.md

C/C++ Memory and String Safety

Actively identify, flag, and provide secure refactoring options for insecure memory and string functions. When generating new code, always default to the safest function available.

Insecure Functions and Safe Alternatives

Critical / High Risk

gets() -- Critical. No bounds checking whatsoever. Always replace with:

  • fgets(char *str, int n, FILE *stream)

strcpy() -- High risk. Copies until null terminator with no bounds check. Replace with:

  • snprintf(), strcpy_s() (C11 Annex K), or strncpy() (with manual null termination)

strcat() -- High risk. Appends with no bounds check. Replace with:

  • snprintf(), strcat_s() (C11 Annex K), or strncat() (with careful handling)

sprintf() / vsprintf() -- High risk. No output buffer bounds check. Replace with:

  • snprintf(), vsprintf_s() (C11 Annex K)
Installs
2
GitHub Stars
52
First Seen
Jul 18, 2026
safe-c-functions — redhatproductsecurity/prodsec-skills