strncpy()
strncpy()
Posted Nov 5, 2007 15:32 UTC (Mon) by nix (subscriber, #2304)In reply to: strncpy() by Ross
Parent article: Daniel Bernstein: ten years of qmail security
It's an excellent design for what it was meant for: filling in ancient Unix directory entries, which had exactly that format (14 byte max, null-terminated if shorter than that). The mistake was putting it in the C library where people might be tempted to use it for other purposes. (See also that horrible pre-stdio function gets(), which I see no uses of other than wrapping in things like libssp, but which still cna never be removed. At least it's hardly used anymore thanks to the warning you get whenever you use it: but strncpy() is used too much to warn about, and there's no decent replacement in libc, although writing one is a matter of five minutes' work.)
