Secure Coding: Lecture Deliver by Sidra Siddiqui
Secure Coding: Lecture Deliver by Sidra Siddiqui
Source
Source
Memory
Memory
Copy
Copy
Operation
Destination Operation
Destination
Memory
Memory
length
• C-style strings consist of a contiguous sequence of characters terminated by and including the
first null character.
• A pointer to a string points to its initial character.
• String length is the number of bytes preceding the null character
• The string value is the sequence of the values of the contained characters, in order.
• The number of bytes required to store a string is the number of characters plus one (x the size
of each character)
Common String Manipulation Errors
• Programming with C-style strings, in C or C++, is error prone.
• Common errors include
• Unbounded string copies
• Null-termination errors
• Truncation
• Write outside array bounds
• Off-by-one errors
• Improper data sanitization