diff options
Diffstat (limited to 'lib/libc/gen')
-rw-r--r-- | lib/libc/gen/basename.c | 7 | ||||
-rw-r--r-- | lib/libc/gen/confstr.c | 5 | ||||
-rw-r--r-- | lib/libc/gen/dirname.c | 7 | ||||
-rw-r--r-- | lib/libc/gen/fstab.c | 5 | ||||
-rw-r--r-- | lib/libc/gen/pwcache.c | 8 | ||||
-rw-r--r-- | lib/libc/gen/syslog.c | 7 | ||||
-rw-r--r-- | lib/libc/gen/timezone.c | 5 |
7 files changed, 18 insertions, 26 deletions
diff --git a/lib/libc/gen/basename.c b/lib/libc/gen/basename.c index 5ffa17abad5..9126b5a1166 100644 --- a/lib/libc/gen/basename.c +++ b/lib/libc/gen/basename.c @@ -1,4 +1,4 @@ -/* $OpenBSD: basename.c,v 1.4 1999/05/30 17:10:30 espie Exp $ */ +/* $OpenBSD: basename.c,v 1.5 2001/06/27 00:58:54 lebel Exp $ */ /* * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> @@ -28,7 +28,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: basename.c,v 1.4 1999/05/30 17:10:30 espie Exp $"; +static char rcsid[] = "$OpenBSD: basename.c,v 1.5 2001/06/27 00:58:54 lebel Exp $"; #endif /* not lint */ #include <errno.h> @@ -69,7 +69,6 @@ basename(path) errno = ENAMETOOLONG; return(NULL); } - (void)strncpy(bname, startp, endp - startp + 1); - bname[endp - startp + 1] = '\0'; + strlcpy(bname, startp, endp - startp + 2); return(bname); } diff --git a/lib/libc/gen/confstr.c b/lib/libc/gen/confstr.c index cb25deed19a..90fbcc5330d 100644 --- a/lib/libc/gen/confstr.c +++ b/lib/libc/gen/confstr.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: confstr.c,v 1.3 1996/09/15 09:30:55 tholo Exp $"; +static char rcsid[] = "$OpenBSD: confstr.c,v 1.4 2001/06/27 00:58:54 lebel Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -73,8 +73,7 @@ confstr(name, buf, len) * POSIX 1003.2 requires partial return of * the string -- that should be *real* useful. */ - (void)strncpy(buf, p, len - 1); - buf[len - 1] = '\0'; + strlcpy(buf, p, len); free(p); } return (tlen + 1); diff --git a/lib/libc/gen/dirname.c b/lib/libc/gen/dirname.c index 573c7d3bfcb..29c6725627a 100644 --- a/lib/libc/gen/dirname.c +++ b/lib/libc/gen/dirname.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dirname.c,v 1.4 1999/05/30 17:10:30 espie Exp $ */ +/* $OpenBSD: dirname.c,v 1.5 2001/06/27 00:58:54 lebel Exp $ */ /* * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> @@ -28,7 +28,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: dirname.c,v 1.4 1999/05/30 17:10:30 espie Exp $"; +static char rcsid[] = "$OpenBSD: dirname.c,v 1.5 2001/06/27 00:58:54 lebel Exp $"; #endif /* not lint */ #include <errno.h> @@ -72,7 +72,6 @@ dirname(path) errno = ENAMETOOLONG; return(NULL); } - (void)strncpy(bname, path, endp - path + 1); - bname[endp - path + 1] = '\0'; + strlcpy(bname, path, endp - path + 2); return(bname); } diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c index bf6da99b94f..4ed7d62cfb5 100644 --- a/lib/libc/gen/fstab.c +++ b/lib/libc/gen/fstab.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: fstab.c,v 1.8 1999/09/03 16:23:18 millert Exp $"; +static char rcsid[] = "$OpenBSD: fstab.c,v 1.9 2001/06/27 00:58:54 lebel Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -124,8 +124,7 @@ fstabscan() _fs_fstab.fs_passno = l; } } - strncpy(subline, _fs_fstab.fs_mntops, sizeof subline-1); - subline[sizeof subline-1] = '\0'; + strlcpy(subline, _fs_fstab.fs_mntops, sizeof subline); for (typexx = 0, cp = strtok(subline, ","); cp; cp = strtok((char *)NULL, ",")) { if (strlen(cp) != 2) diff --git a/lib/libc/gen/pwcache.c b/lib/libc/gen/pwcache.c index 509bdbb10b5..f09f291aa69 100644 --- a/lib/libc/gen/pwcache.c +++ b/lib/libc/gen/pwcache.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: pwcache.c,v 1.4 2001/01/31 17:42:25 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: pwcache.c,v 1.5 2001/06/27 00:58:54 lebel Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -72,8 +72,7 @@ user_from_uid(uid, nouser) return (nbuf); } cp->uid = uid; - (void)strncpy(cp->name, pw->pw_name, _PW_NAME_LEN); - cp->name[_PW_NAME_LEN] = '\0'; + strlcpy(cp->name, pw->pw_name, sizeof(cp->name)); } return (cp->name); } @@ -105,8 +104,7 @@ group_from_gid(gid, nogroup) return (nbuf); } cp->gid = gid; - (void)strncpy(cp->name, gr->gr_name, _PW_NAME_LEN); - cp->name[_PW_NAME_LEN] = '\0'; + strlcpy(cp->name, gr->gr_name, sizeof(cp->name)); } return (cp->name); } diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c index 11a106ba85c..b33a663e406 100644 --- a/lib/libc/gen/syslog.c +++ b/lib/libc/gen/syslog.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: syslog.c,v 1.9 2000/01/02 23:35:58 hugh Exp $"; +static char rcsid[] = "$OpenBSD: syslog.c,v 1.10 2001/06/27 00:58:54 lebel Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -278,9 +278,8 @@ connectlog() memset(&SyslogAddr, '\0', sizeof(SyslogAddr)); SyslogAddr.sun_len = sizeof(SyslogAddr); SyslogAddr.sun_family = AF_UNIX; - (void)strncpy(SyslogAddr.sun_path, _PATH_LOG, - sizeof(SyslogAddr.sun_path) - 1); - SyslogAddr.sun_path[sizeof(SyslogAddr.sun_path) - 1] = '\0'; + strlcpy(SyslogAddr.sun_path, _PATH_LOG, + sizeof(SyslogAddr.sun_path)); if (connect(LogFile, (struct sockaddr *)&SyslogAddr, sizeof(SyslogAddr)) == -1) { (void)close(LogFile); diff --git a/lib/libc/gen/timezone.c b/lib/libc/gen/timezone.c index d9a05408981..498243f8c3f 100644 --- a/lib/libc/gen/timezone.c +++ b/lib/libc/gen/timezone.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: timezone.c,v 1.4 1997/12/19 09:43:16 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: timezone.c,v 1.5 2001/06/27 00:58:54 lebel Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -67,8 +67,7 @@ timezone(zone, dst) if (dst) return(++end); *end = '\0'; - (void)strncpy(czone,beg,sizeof(czone) - 1); - czone[sizeof(czone) - 1] = '\0'; + strlcpy(czone,beg,sizeof(czone)); *end = ','; return(czone); } |