\"The average man does not want to be free. He simply wants to be safe.\" - H. L. Menken
I am attempting to write very secure C. Below I
Don't use gets() for input, use fgets(). To use fgets(), if your buffer is automatically allocated (i.e., "on the stack"), then use this idiom:
char buf[N];
...
if (fgets(buf, sizeof buf, fp) != NULL)
This will keep working if you decide to change the size of buf. I prefer this form to:
#define N whatever
char buf[N];
if (fgets(buf, N, fp) != NULL)
because the first form uses buf to determine the second argument, and is clearer.
Check the return value of fclose().