Specifically with C, buffer overruns such as Kyle's are a well-known error. In this case, the problem could be solved by calling strncpy() rather than strcpy(), which allows the program to limit to copying a maximum of 32 characters.
Also, teach Kyle to use lint and/or other code checking tools to find these sorts of mistakes.
An arguably better solution would be to teach Kyle to use a couple lines of shell script instead of writing C code for something this trivial. Of course, every language has its security problems, so this is really just changing problems rather than solving them.
Specifically with C, buffer overruns such as Kyle's are a well-known error. In this case, the problem could be solved by calling strncpy() rather than strcpy(), which allows the program to limit to copying a maximum of 32 characters.
Also, teach Kyle to use lint and/or other code checking tools to find these sorts of mistakes.
An arguably better solution would be to teach Kyle to use a couple lines of shell script instead of writing C code for something this trivial. Of course, every language has its security problems, so this is really just changing problems rather than solving them.
thank you! I couldn't possibly answer better. Poor Kyle, though, you are being too hard on him hahaha
@tanjent , thank you for your feedback, I agree with you each language has their security issues, the most important thing is how to solved them :)