3 ms·
strncpy is a dangerous function because it doesn't nul terminate on overflow. The danger is that it's named misleadingly (str* functions otherwise always work
by syncsynchalt 6y ago
strncpy is a dangerous function because it doesn't nul terminate on overflow. The danger is that it's named misleadingly (str* functions otherwise always work in nul-terminated strings).
(strcpy is just banned because there's no bounds check, and they want to force use of strlcpy instead).
- loeg 6y agostrncpy also has the dubious behavior of zero-filling out to N even if strlen(src) is much shorter than N.