strncpy() history
strncpy() history
Posted May 25, 2017 1:36 UTC (Thu) by rlhamil (guest, #6472)In reply to: strncpy() history by danscox
Parent article: The ups and downs of strlcpy()
unixv7# time find /usr/src /usr/sys -type f -name '*.[ch]' -exec grep strncpy /dev/null {} \;
/usr/src/libc/gen/strncpy.c:strncpy(s1, s2, n)
/usr/src/cmd/crypt.c: strncpy(buf, pw, 8);
/usr/src/cmd/ed.c: strncpy(buf, keyp, 8);
/usr/src/cmd/login.c:#define SCPYN(a, b) strncpy(a, b, sizeof(a))
/usr/src/cmd/mkdir.c: strncpy(pname, d, slash);
/usr/src/cmd/atrun.c: strncpy(file, dirent.d_name, DIRSIZ);
/usr/src/cmd/xsend/lib.c: strncpy(buf, s, 10);
/usr/src/cmd/ranlib.c: strncpy(firstname, arp.ar_name, 14);
real 7.0
user 2.0
sys 4.5
Without looking further, three appear to deal with pathname components, three deal with other things, one is a macro (turns out it was for a not-necessarily-terminated utmp.ut_name field), and one is the definition of strlcpy.
(Log in to post comments)


