Alternative functions that limit the number of bytes copied are often recommended to mitigate buffer overflow vulnerabilities. For example:
strncpy()
instead ofstrcpy()
strncat()
instead ofstrcat()
fgets()
instead ofgets()
snprintf()
instead ofsprintf()
Wiki Markup |
---|
These functions truncate strings that exceed the specified limits. Additionally, some functions such as {{strncpy()}} do not guarantee that the resulting string is null- terminated \[[STR32-C. Null- terminate byte strings as required]\]. |
...