diff options
author | 2001-05-11 18:35:21 +0000 | |
---|---|---|
committer | 2001-05-11 18:35:21 +0000 | |
commit | 2dc3481ad900d4faeea1311d5e2541ec61e67aeb (patch) | |
tree | a4ee05049c82700e291c1e54ff9eecf8f6cbaae7 | |
parent | sync (diff) | |
download | wireguard-openbsd-2dc3481ad900d4faeea1311d5e2541ec61e67aeb.tar.xz wireguard-openbsd-2dc3481ad900d4faeea1311d5e2541ec61e67aeb.zip |
use strlcpy instead of strncpy+a[len-1]='\0'
-rw-r--r-- | bin/csh/sem.c | 16 | ||||
-rw-r--r-- | bin/df/ext2fs_df.c | 5 | ||||
-rw-r--r-- | bin/df/ffs_df.c | 5 | ||||
-rw-r--r-- | bin/df/lfs_df.c | 5 | ||||
-rw-r--r-- | bin/rcp/rcp.c | 7 | ||||
-rw-r--r-- | sbin/mountd/mountd.c | 20 |
6 files changed, 22 insertions, 36 deletions
diff --git a/bin/csh/sem.c b/bin/csh/sem.c index 050ed7de427..62d27452e5f 100644 --- a/bin/csh/sem.c +++ b/bin/csh/sem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sem.c,v 1.6 1998/08/26 08:00:07 deraadt Exp $ */ +/* $OpenBSD: sem.c,v 1.7 2001/05/11 18:38:44 mickey Exp $ */ /* $NetBSD: sem.c,v 1.9 1995/09/27 00:38:50 jtc Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)sem.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: sem.c,v 1.6 1998/08/26 08:00:07 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: sem.c,v 1.7 2001/05/11 18:38:44 mickey Exp $"; #endif #endif /* not lint */ @@ -167,7 +167,7 @@ execute(t, wanttty, pipein, pipeout) * Check if we have a builtin function and remember which one. */ bifunc = isbfunc(t); - if (noexec) { + if (noexec) { /* * Continue for builtins that are part of the scripting language */ @@ -452,7 +452,7 @@ execute(t, wanttty, pipein, pipeout) } /* * Fall through for all breaks from switch - * + * * If there will be no more executions of this command, flush all file * descriptors. Places that turn on the F_REPEAT bit are responsible for * doing donefds after the last re-execution @@ -490,7 +490,7 @@ int i; * * I don't know what is best to do. I think that Ambiguous is better * than restructuring the command vector, because the user can get - * unexpected results. In any case, the command vector restructuring + * unexpected results. In any case, the command vector restructuring * code is present and the user can choose it by setting noambiguous */ static Char * @@ -558,8 +558,7 @@ doio(t, pipein, pipeout) (void) dcopy(SHOUT, 1); (void) dcopy(SHERR, 2); cp = splicepipe(t, t->t_dlef); - (void) strncpy(tmp, short2str(cp), sizeof tmp-1); - tmp[sizeof tmp-1] = '\0'; + strlcpy(tmp, short2str(cp), sizeof tmp); xfree((ptr_t) cp); if ((fd = open(tmp, O_RDONLY)) < 0) stderror(ERR_SYSTEM, tmp, strerror(errno)); @@ -585,8 +584,7 @@ doio(t, pipein, pipeout) char tmp[MAXPATHLEN]; cp = splicepipe(t, t->t_drit); - (void) strncpy(tmp, short2str(cp), sizeof tmp-1); - tmp[sizeof tmp-1] = '\0'; + strlcpy(tmp, short2str(cp), sizeof tmp); xfree((ptr_t) cp); /* * so > /dev/std{out,err} work diff --git a/bin/df/ext2fs_df.c b/bin/df/ext2fs_df.c index 60bef0bf5e2..de3612862c6 100644 --- a/bin/df/ext2fs_df.c +++ b/bin/df/ext2fs_df.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_df.c,v 1.6 2001/01/28 23:04:55 niklas Exp $ */ +/* $OpenBSD: ext2fs_df.c,v 1.7 2001/05/11 18:40:46 mickey Exp $ */ /* * This file is substantially derived from src/sys/ufs/ext2fs/ext2fs_vfsops.c:e2fs_statfs(). @@ -108,7 +108,6 @@ e2fs_df(rfd, file, sfsp) mntpt = ""; memmove(&sfsp->f_mntonname[0], mntpt, MNAMELEN); memmove(&sfsp->f_mntfromname[0], file, MNAMELEN); - strncpy(sfsp->f_fstypename, MOUNT_EXT2FS, MFSNAMELEN-1); - sfsp->f_fstypename[MFSNAMELEN-1] = '\0'; + strlcpy(sfsp->f_fstypename, MOUNT_EXT2FS, MFSNAMELEN); return (0); } diff --git a/bin/df/ffs_df.c b/bin/df/ffs_df.c index f166b0c657d..b4081f7f019 100644 --- a/bin/df/ffs_df.c +++ b/bin/df/ffs_df.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_df.c,v 1.5 2001/01/28 23:04:55 niklas Exp $ */ +/* $OpenBSD: ffs_df.c,v 1.6 2001/05/11 18:40:46 mickey Exp $ */ /* * Copyright (c) 1980, 1990, 1993, 1994 @@ -95,7 +95,6 @@ ffs_df(rfd, file, sfsp) mntpt = ""; memmove(&sfsp->f_mntonname[0], mntpt, MNAMELEN); memmove(&sfsp->f_mntfromname[0], file, MNAMELEN); - strncpy(sfsp->f_fstypename, MOUNT_FFS, MFSNAMELEN-1); - sfsp->f_fstypename[MFSNAMELEN-1] = '\0'; + strlcpy(sfsp->f_fstypename, MOUNT_FFS, MFSNAMELEN); return (0); } diff --git a/bin/df/lfs_df.c b/bin/df/lfs_df.c index d876105f803..f5824fd8bf0 100644 --- a/bin/df/lfs_df.c +++ b/bin/df/lfs_df.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lfs_df.c,v 1.5 2001/01/28 23:04:55 niklas Exp $ */ +/* $OpenBSD: lfs_df.c,v 1.6 2001/05/11 18:40:46 mickey Exp $ */ /* * This file is substantially duplicated from src/sys/ufs/lfs/lfs_vfsops.c:lfs_statfs(). @@ -97,7 +97,6 @@ lfs_df(rfd, file, sfsp) mntpt = ""; memmove(&sfsp->f_mntonname[0], mntpt, MNAMELEN); memmove(&sfsp->f_mntfromname[0], file, MNAMELEN); - strncpy(sfsp->f_fstypename, MOUNT_LFS, MFSNAMELEN-1); - sfsp->f_fstypename[MFSNAMELEN-1] = '\0'; + strlcpy(sfsp->f_fstypename, MOUNT_LFS, MFSNAMELEN); return (0); } diff --git a/bin/rcp/rcp.c b/bin/rcp/rcp.c index bfdb16bc29b..2c1fd243c86 100644 --- a/bin/rcp/rcp.c +++ b/bin/rcp/rcp.c @@ -1,5 +1,5 @@ +/* $OpenBSD: rcp.c,v 1.20 2001/05/11 18:43:40 mickey Exp $ */ /* $NetBSD: rcp.c,v 1.9 1995/03/21 08:19:06 cgd Exp $ */ -/* $OpenBSD: rcp.c,v 1.19 2001/04/06 16:46:59 deraadt Exp $ */ /* * Copyright (c) 1983, 1990, 1992, 1993 @@ -80,7 +80,7 @@ static char rcsid[] = "$NetBSD: rcp.c,v 1.9 1995/03/21 08:19:06 cgd Exp $"; char dst_realm_buf[REALM_SZ]; char *dest_realm = NULL; int use_kerberos = 1; -CREDENTIALS cred; +CREDENTIALS cred; Key_schedule schedule; extern char *krb_realmofhost(); int doencrypt = 0; @@ -134,8 +134,7 @@ main(argc, argv) #ifdef KERBEROS case 'k': dest_realm = dst_realm_buf; - (void)strncpy(dst_realm_buf, optarg, REALM_SZ-1); - dst_realm_buf[REALM_SZ-1] = '\0'; + strlcpy(dst_realm_buf, optarg, sizeof(dst_realm_buf)); break; case 'x': doencrypt = 1; diff --git a/sbin/mountd/mountd.c b/sbin/mountd/mountd.c index bfc1d8a03f7..11a53c7dd08 100644 --- a/sbin/mountd/mountd.c +++ b/sbin/mountd/mountd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mountd.c,v 1.35 2001/01/17 19:27:11 deraadt Exp $ */ +/* $OpenBSD: mountd.c,v 1.36 2001/05/11 18:35:21 mickey Exp $ */ /* $NetBSD: mountd.c,v 1.31 1996/02/18 11:57:53 fvdl Exp $ */ /* @@ -259,11 +259,7 @@ main(argc, argv) exphead = NULL; mlhead = NULL; - if (argc == 1) - strncpy(exname, *argv, sizeof(exname)-1); - else - strncpy(exname, _PATH_EXPORTS, sizeof exname-1); - exname[sizeof(exname)-1] = '\0'; + strlcpy(exname, argc == 1? *argv : _PATH_EXPORTS, sizeof(exname)); openlog("mountd", LOG_PID, LOG_DAEMON); if (debug) @@ -1941,10 +1937,8 @@ get_mountlist() if (host == NULL || dirp == NULL) continue; mlp = (struct mountlist *)malloc(sizeof (*mlp)); - strncpy(mlp->ml_host, host, RPCMNT_NAMELEN); - mlp->ml_host[RPCMNT_NAMELEN] = '\0'; - strncpy(mlp->ml_dirp, dirp, RPCMNT_PATHLEN); - mlp->ml_dirp[RPCMNT_PATHLEN] = '\0'; + strlcpy(mlp->ml_host, host, sizeof(mlp->ml_host)); + strlcpy(mlp->ml_dirp, dirp, sizeof(mlp->ml_dirp)); mlp->ml_next = NULL; *mlpp = mlp; mlpp = &mlp->ml_next; @@ -2006,10 +2000,8 @@ add_mlist(hostp, dirp) mlp = mlp->ml_next; } mlp = (struct mountlist *)malloc(sizeof (*mlp)); - strncpy(mlp->ml_host, hostp, RPCMNT_NAMELEN); - mlp->ml_host[RPCMNT_NAMELEN] = '\0'; - strncpy(mlp->ml_dirp, dirp, RPCMNT_PATHLEN); - mlp->ml_dirp[RPCMNT_PATHLEN] = '\0'; + strlcpy(mlp->ml_host, hostp, sizeof(mlp->ml_host)); + strlcpy(mlp->ml_dirp, dirp, sizeof(mlp->ml_dirp, dirp)); mlp->ml_next = NULL; *mlpp = mlp; if ((mlfile = fopen(_PATH_RMOUNTLIST, "a")) == NULL) { |