Re:strcpy: A niche function you don't need
by spatulon on Saturday July 31, 2021 @09:02AM
(#28017753)
Note that snprintf returns the number of bytes that would have been written if the dest buffer were large enough, not the number of bytes actually written. I've seen a few projects misunderstand that and write code like this:
That will cause a buffer overflow: if iteration n gets truncated because the dest buffer fills up, iteration n+1 will write past the end of the buffer.
[ Parent
| on HN ]
There are no comments on this comment yet.