View Single Post
Old 2012-05-30, 20:00   #9
chalsall
If I May
 
chalsall's Avatar
 
"Chris Halsall"
Sep 2002
Barbados

2×5,023 Posts
Default

Quote:
Originally Posted by kjaget View Post
strncpy() isn't a safe version of strcpy(). It doesn't report errors and will not nul-terminate a string if it hits the size limit. That means it itself won't cause buffer overruns, but any subsequent use of the results of likely will if your source string was too long.
Code:
strncpy(dest, src, length);
dest[length-1]=0;
...is pretty safe....
chalsall is offline   Reply With Quote