diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2002-06-10 21:07:15 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2002-06-10 21:07:15 +0000 |
commit | dac952ba779c7d98abb2f40fd0e5cb17b44ea8d8 (patch) | |
tree | dddc63f27f9455536267f52154986906ef261f67 /usr.sbin/amd | |
parent | d8a53c219e06e22f583c6b2a38a80ca759b8df5b (diff) |
strlcpy, strlcat
Diffstat (limited to 'usr.sbin/amd')
-rw-r--r-- | usr.sbin/amd/amd/get_args.c | 6 | ||||
-rw-r--r-- | usr.sbin/amd/amd/host_ops.c | 4 | ||||
-rw-r--r-- | usr.sbin/amd/amd/info_hes.c | 5 | ||||
-rw-r--r-- | usr.sbin/amd/amd/info_passwd.c | 8 | ||||
-rw-r--r-- | usr.sbin/amd/amd/mount_fs.c | 5 | ||||
-rw-r--r-- | usr.sbin/amd/amd/nfs_ops.c | 6 | ||||
-rw-r--r-- | usr.sbin/amd/config/mtab_file.c | 4 | ||||
-rw-r--r-- | usr.sbin/amd/fsinfo/fsi_analyze.c | 8 | ||||
-rw-r--r-- | usr.sbin/amd/fsinfo/fsinfo.c | 4 | ||||
-rw-r--r-- | usr.sbin/amd/fsinfo/wr_atab.c | 13 |
10 files changed, 34 insertions, 29 deletions
diff --git a/usr.sbin/amd/amd/get_args.c b/usr.sbin/amd/amd/get_args.c index 6303354c03a..e00f9051d3f 100644 --- a/usr.sbin/amd/amd/get_args.c +++ b/usr.sbin/amd/amd/get_args.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * from: @(#)get_args.c 8.1 (Berkeley) 6/6/93 - * $Id: get_args.c,v 1.3 2002/05/25 07:37:19 deraadt Exp $ + * $Id: get_args.c,v 1.4 2002/06/10 21:07:14 itojun Exp $ */ /* @@ -271,8 +271,8 @@ char *v[]; hostdomain = sub_domain; if (*hostdomain == '.') hostdomain++; - strcat(hostd, "."); - strcat(hostd, hostdomain); + strlcat(hostd, ".", 2 * MAXHOSTNAMELEN); + strlcat(hostd, hostdomain, 2 * MAXHOSTNAMELEN); #ifdef UPDATE_MTAB #ifdef DEBUG diff --git a/usr.sbin/amd/amd/host_ops.c b/usr.sbin/amd/amd/host_ops.c index 1bbc996d64b..6d947742c0a 100644 --- a/usr.sbin/amd/amd/host_ops.c +++ b/usr.sbin/amd/amd/host_ops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: host_ops.c,v 1.4 2001/03/02 06:22:02 deraadt Exp $ */ +/* $OpenBSD: host_ops.c,v 1.5 2002/06/10 21:07:14 itojun Exp $ */ /* * Copyright (c) 1990 Jan-Simon Pendry @@ -367,7 +367,7 @@ mntfs *mf; * error code 0 at the end. If they all fail then return * the last error code. */ - strncpy(fs_name, mf->mf_info, sizeof(fs_name)); + strlcpy(fs_name, mf->mf_info, sizeof(fs_name)); if ((rfs_dir = strchr(fs_name, ':')) == (char *) 0) { plog(XLOG_FATAL, "host_fmount: mf_info has no colon"); error = EINVAL; diff --git a/usr.sbin/amd/amd/info_hes.c b/usr.sbin/amd/amd/info_hes.c index 465d5cc82de..ef36b9f2e6f 100644 --- a/usr.sbin/amd/amd/info_hes.c +++ b/usr.sbin/amd/amd/info_hes.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * from: @(#)info_hes.c 8.1 (Berkeley) 6/6/93 - * $Id: info_hes.c,v 1.5 2001/08/12 12:03:03 heko Exp $ + * $Id: info_hes.c,v 1.6 2002/06/10 21:07:14 itojun Exp $ */ /* @@ -653,7 +653,8 @@ char *domain; #ifdef DEBUG dlog("hs_get_ns_list: Saving name %s", name); #endif - strncpy(nsname[numns], name, MAXDATA); + strlcpy(nsname[numns], name, + sizeof(nsname[numns])); nshaveaddr[numns] = 0; numns++; } diff --git a/usr.sbin/amd/amd/info_passwd.c b/usr.sbin/amd/amd/info_passwd.c index baf7ce2eaca..b1852776d19 100644 --- a/usr.sbin/amd/amd/info_passwd.c +++ b/usr.sbin/amd/amd/info_passwd.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * from: @(#)info_passwd.c 8.1 (Berkeley) 6/6/93 - * $Id: info_passwd.c,v 1.1 1995/10/18 08:47:10 deraadt Exp $ + * $Id: info_passwd.c,v 1.2 2002/06/10 21:07:14 itojun Exp $ */ /* @@ -125,11 +125,11 @@ time_t *tp; do { q = strrchr(p, '/'); if (q) { - strcat(rhost, q + 1); - strcat(rhost, "."); + strlcat(rhost, q + 1, sizeof(rhost)); + strlcat(rhost, ".", sizeof(rhost)); *q = '\0'; } else { - strcat(rhost, p); + strlcat(rhost, p, sizeof(rhost)); } } while (q); /* diff --git a/usr.sbin/amd/amd/mount_fs.c b/usr.sbin/amd/amd/mount_fs.c index 22d5dc9002e..9fd42107319 100644 --- a/usr.sbin/amd/amd/mount_fs.c +++ b/usr.sbin/amd/amd/mount_fs.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * from: @(#)mount_fs.c 8.1 (Berkeley) 6/6/93 - * $Id: mount_fs.c,v 1.5 2001/03/02 06:22:03 deraadt Exp $ + * $Id: mount_fs.c,v 1.6 2002/06/10 21:07:14 itojun Exp $ */ #include "am.h" @@ -256,8 +256,7 @@ char *opt; char *f; char *o = t; int l = strlen(opt); - strncpy(t, mnt->mnt_opts, MNTMAXSTR - 1); - t[MNTMAXSTR - 1] = 0; + strlcpy(t, mnt->mnt_opts, sizeof(t)); while (*(f = nextmntopt(&o))) if (strncmp(opt, f, l) == 0) diff --git a/usr.sbin/amd/amd/nfs_ops.c b/usr.sbin/amd/amd/nfs_ops.c index 2d357dfb296..3c80be1524a 100644 --- a/usr.sbin/amd/amd/nfs_ops.c +++ b/usr.sbin/amd/amd/nfs_ops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_ops.c,v 1.10 2002/05/26 02:49:50 deraadt Exp $ */ +/* $OpenBSD: nfs_ops.c,v 1.11 2002/06/10 21:07:14 itojun Exp $ */ /*- * Copyright (c) 1990 Jan-Simon Pendry @@ -40,7 +40,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)nfs_ops.c 8.1 (Berkeley) 6/6/93";*/ -static char *rcsid = "$OpenBSD: nfs_ops.c,v 1.10 2002/05/26 02:49:50 deraadt Exp $"; +static char *rcsid = "$OpenBSD: nfs_ops.c,v 1.11 2002/06/10 21:07:14 itojun Exp $"; #endif /* not lint */ #include "am.h" @@ -507,7 +507,7 @@ mntfs *mf; #ifndef NFS_ARGS_NEEDS_PATH *colon = '\0'; #endif - strncpy(host, fs_name, sizeof(host)); + strlcpy(host, fs_name, sizeof(host)); #ifndef NFS_ARGS_NEEDS_PATH *colon = ':'; #endif /* NFS_ARGS_NEEDS_PATH */ diff --git a/usr.sbin/amd/config/mtab_file.c b/usr.sbin/amd/config/mtab_file.c index 93151776427..31906aba9fc 100644 --- a/usr.sbin/amd/config/mtab_file.c +++ b/usr.sbin/amd/config/mtab_file.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * from: @(#)mtab_file.c 8.1 (Berkeley) 6/6/93 - * $Id: mtab_file.c,v 1.1 1995/10/18 08:47:14 deraadt Exp $ + * $Id: mtab_file.c,v 1.2 2002/06/10 21:07:14 itojun Exp $ */ #include "am.h" @@ -282,7 +282,7 @@ mntlist *mp; plog(XLOG_WARNING, "No '/' in mtab (%s), using \".\" as tmp directory", mtab); tmpname[0] = '.'; tmpname[1] = '\0'; } - strcat(tmpname, "/mtabXXXXXX"); + strlcat(tmpname, "/mtabXXXXXX", sizeof(tmpname)); mktemp(tmpname); retries = 0; enfile1: diff --git a/usr.sbin/amd/fsinfo/fsi_analyze.c b/usr.sbin/amd/fsinfo/fsi_analyze.c index a3d7f9e8a3e..e0becb3dfbb 100644 --- a/usr.sbin/amd/fsinfo/fsi_analyze.c +++ b/usr.sbin/amd/fsinfo/fsi_analyze.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * from: @(#)fsi_analyze.c 8.1 (Berkeley) 6/6/93 - * $Id: fsi_analyze.c,v 1.1 1995/10/18 08:47:18 deraadt Exp $ + * $Id: fsi_analyze.c,v 1.2 2002/06/10 21:07:14 itojun Exp $ */ /* @@ -122,10 +122,10 @@ char *hn; d = strrchr(p, '.'); if (d) { *d = 0; - strcat(path, d+1); - strcat(path, "/"); + strlcat(path, d+1, sizeof(path)); + strlcat(path, "/", sizeof(path)); } else { - strcat(path, p); + strlcat(path, p, sizeof(path)); } } while (d); diff --git a/usr.sbin/amd/fsinfo/fsinfo.c b/usr.sbin/amd/fsinfo/fsinfo.c index 5466843846d..de4923c2f3f 100644 --- a/usr.sbin/amd/fsinfo/fsinfo.c +++ b/usr.sbin/amd/fsinfo/fsinfo.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * from: @(#)fsinfo.c 8.1 (Berkeley) 6/6/93 - * $Id: fsinfo.c,v 1.4 2001/01/02 20:01:35 mickey Exp $ + * $Id: fsinfo.c,v 1.5 2002/06/10 21:07:14 itojun Exp $ */ #ifndef lint @@ -107,7 +107,7 @@ char *v[]; dumpset_pref = optarg; break; case 'h': - strncpy(hostname, optarg, sizeof(hostname)-1); + strlcpy(hostname, optarg, sizeof(hostname)); break; case 'e': if (exportfs_pref) diff --git a/usr.sbin/amd/fsinfo/wr_atab.c b/usr.sbin/amd/fsinfo/wr_atab.c index baae2b6105c..15ca7f0cf99 100644 --- a/usr.sbin/amd/fsinfo/wr_atab.c +++ b/usr.sbin/amd/fsinfo/wr_atab.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * from: @(#)wr_atab.c 8.1 (Berkeley) 6/6/93 - * $Id: wr_atab.c,v 1.1 1995/10/18 08:47:19 deraadt Exp $ + * $Id: wr_atab.c,v 1.2 2002/06/10 21:07:14 itojun Exp $ */ #include "../fsinfo/fsinfo.h" @@ -177,12 +177,17 @@ int sk; char sublink[1024]; sublink[0] = '\0'; if (exp_namelen < namelen) { - strcat(sublink, mp->m_name + exp_namelen + 1); + strlcat(sublink, + mp->m_name + exp_namelen + 1, + sizeof(sublink)); if (mvolnlen < volnlen) - strcat(sublink, "/"); + strlcat(sublink, "/", + sizeof(sublink)); } if (mvolnlen < volnlen) - strcat(sublink, ap->a_volname + mvolnlen + 1); + strlcat(sublink, + ap->a_volname + mvolnlen + 1, + sizeof(sublink)); fprintf(af, ";sublink:=%s", sublink); } |