Wednesday, December 1, 2010

Unsafe Functions

The following functions that are unsafe: strcpy() strcat() sprintf().

This is because there is no limit on what is being written to the destination. Instead strncpy(), strncat(), and snprintf() should be used, because you can limit what is being written to the destination, and also guarantee that the string is null terminated. The problem with strncpy(), and strncat() is they do not guarantee the array of characters will be null-terminated.

No comments:

Post a Comment