Safer string manipulation in C

strncpy does not append a terminating 0 if the source buffer if it’s too long to fit into the destination buffer. strncat requires the programmer to keep track of how much space there is left in the destination buffer. The size parameter of strncat does not include the terminating null character, where as the size of strncpy does.

strlcat and strlcpy replaces strncat and strncpy. The both take the destination buffer size as the size parameter and they both always append a terminating 0 to the destination if the size of the destination buffer is greater than zero. They are available under the BSD license which means that they are freely available for both open source and commercial usage.
http://www.gratisoft.us/todd/papers/strlcpy.html

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s