While coding, sometimes you may use functions that don't check or constrain the data entered by the user. The user either may enter incorrect data or content that might be larger than the capacity of the receiving variable. In such a situation, a buffer overflow or segmentation fault may occur. Consequently, the program will give an erroneous output.
In this chapter, we will use the following recipes to see how we can error-proof the entering of data in a program:
- Avoiding buffer overflow while reading strings from the keyboard
- Writing secure code while copying strings
- Avoiding errors while string formatting
- Avoid vulnerabilities while accessing files in C