Notes on C Flashcards
What are the advantages?
- Efficient
- Fast
- Low-level capabilities
- Portable
These features improve performance and give more control to the programmer
What are the disadvantages?
Safety checks are not enforced
- Bounds checking
- Type safety checking
- Range checking
Programmer responsible for memory and resource management
Due to the amount of control given programmer requires a good deal of care, knowledge and skill
Size of data types
char: 8 bits
short int: 16 bits
int: 32 bits
long int: 64 bits
float: 32
double: 64
What are the integer security vulnerabilities?
Casting issues (converting from bigger to smaller data type or between incompatible types)
Integer overflow (value of integer goes beyond the maximum or minimum value resulting in the value being wrapped around the other end of the allowed range)
What are the array security vulnerabilities?
Bounds checking (no built-in out-of-bounds checks for arrays, vulnerable to overflow)
Determining array size (using sizeof() when a raise out of scope will return standard pointer size, logical error)
What are the string security vulnerabilities?
Dangerous string functions (no bounds checking or length restriction)
Off-by-one/null-termination