Defenses: Write Correct Code
- Never pass user data as the format argument. printf(user_input); /* NO */ printf("
- Enable compiler diagnostics:
-Wformat—- checks format/argument type mismatches.-Wformat-security—- flags non-literal formats with no args.-Werror=format-security—- make it a hard build error.- Static analyzers and code review specifically hunt the "non-literal format" pattern.