summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-06-11 05:29:56 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-06-11 05:29:56 +0000
commitc2384b027be35ad0d56abd0a775e8706ba286ec7 (patch)
treea0c7dfc0dec5747c3a7ff09f912571d2a91e5b60 /usr.sbin
parent1e2ae257826f6e35ff6124fe764057666daf08c3 (diff)
use snprintf.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/amd/amd/afs_ops.c14
-rw-r--r--usr.sbin/amd/amd/am_ops.c5
-rw-r--r--usr.sbin/amd/amd/amd.c4
-rw-r--r--usr.sbin/amd/amd/amq_subr.c4
-rw-r--r--usr.sbin/amd/amd/host_ops.c4
-rw-r--r--usr.sbin/amd/amd/info_hes.c10
-rw-r--r--usr.sbin/amd/amd/info_passwd.c4
-rw-r--r--usr.sbin/amd/amd/info_union.c8
-rw-r--r--usr.sbin/amd/amd/mapc.c6
-rw-r--r--usr.sbin/amd/amd/mount_fs.c8
-rw-r--r--usr.sbin/amd/amd/nfs_ops.c7
-rw-r--r--usr.sbin/amd/amd/opts.c4
-rw-r--r--usr.sbin/amd/amd/rpc_fwd.c4
-rw-r--r--usr.sbin/amd/amd/util.c9
-rw-r--r--usr.sbin/amd/amd/wire.c6
-rw-r--r--usr.sbin/amd/fsinfo/fsi_analyze.c8
-rw-r--r--usr.sbin/amd/fsinfo/fsi_util.c13
-rw-r--r--usr.sbin/amd/fsinfo/wr_atab.c4
-rw-r--r--usr.sbin/amd/include/am.h4
-rw-r--r--usr.sbin/amd/mk-amd-map/mk-amd-map.c16
20 files changed, 75 insertions, 67 deletions
diff --git a/usr.sbin/amd/amd/afs_ops.c b/usr.sbin/amd/amd/afs_ops.c
index 1d33b1b798b..4f3d330d25d 100644
--- a/usr.sbin/amd/amd/afs_ops.c
+++ b/usr.sbin/amd/amd/afs_ops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: afs_ops.c,v 1.4 2002/05/26 02:49:50 deraadt Exp $ */
+/* $OpenBSD: afs_ops.c,v 1.5 2002/06/11 05:29:54 itojun Exp $ */
/*
* Copyright (c) 1990 Jan-Simon Pendry
@@ -176,10 +176,10 @@ char *opts;
#define SHORT_MOUNT_NAME
#endif /* HOSTNAMESZ */
#ifdef SHORT_MOUNT_NAME
- sprintf(fs_hostname, "amd:%ld",
+ snprintf(fs_hostname, sizeof(fs_hostname), "amd:%ld",
foreground ? (long)mypid : (long)getppid());
#else
- sprintf(fs_hostname, "pid%ld@%s:%s",
+ snprintf(fs_hostname, sizeof(fs_hostname), "pid%ld@%s:%s",
foreground ? (long)mypid : (long)getppid(), hostname, dir);
#endif /* SHORT_MOUNT_NAME */
nfs_args.hostname = fs_hostname;
@@ -370,7 +370,7 @@ am_node *mp;
/*
* Construct some mount options
*/
- sprintf(opts,
+ snprintf(opts, sizeof(opts),
#ifdef MNTOPT_INTR
"%s,%s,%s=%d,%s=%d,%s=%d,%s",
MNTOPT_INTR,
@@ -1366,7 +1366,7 @@ in_progrss:
* map for it.
*/
if (mp->am_pref) {
- sprintf(path_name, "%s%s", mp->am_pref, fname);
+ snprintf(path_name, sizeof(path_name), "%s%s", mp->am_pref, fname);
pfname = path_name;
} else {
pfname = fname;
@@ -1475,7 +1475,9 @@ in_progrss:
*/
if (*auto_opts && *dfl) {
char *nopts = (char *) xmalloc(strlen(auto_opts)+strlen(dfl)+2);
- sprintf(nopts, "%s;%s", dfl, auto_opts);
+ snprintf(nopts,
+ strlen(auto_opts) + strlen(dfl) + 2,
+ "%s;%s", dfl, auto_opts);
free(auto_opts);
auto_opts = nopts;
} else if (*dfl) {
diff --git a/usr.sbin/amd/amd/am_ops.c b/usr.sbin/amd/amd/am_ops.c
index 075fa7645cc..415ee6aba56 100644
--- a/usr.sbin/amd/amd/am_ops.c
+++ b/usr.sbin/amd/amd/am_ops.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)am_ops.c 8.1 (Berkeley) 6/6/93
- * $Id: am_ops.c,v 1.2 2001/03/02 06:22:01 deraadt Exp $
+ * $Id: am_ops.c,v 1.3 2002/06/11 05:29:54 itojun Exp $
*/
#include "am.h"
@@ -111,7 +111,8 @@ char *map;
char *sublink = fs ? strchr(fs+1, ':') : 0;
char keybuf[MAXPATHLEN];
- sprintf(keybuf, "type:=nfs;rhost:=%s;rfs:=%s;sublink:=%s;opts:=%s", host,
+ snprintf(keybuf, sizeof(keybuf),
+ "type:=nfs;rhost:=%s;rfs:=%s;sublink:=%s;opts:=%s", host,
fs ? fs+1 : "",
sublink ? sublink+1 : "",
g_key);
diff --git a/usr.sbin/amd/amd/amd.c b/usr.sbin/amd/amd/amd.c
index 52b4a39d446..b3bdfbc07cf 100644
--- a/usr.sbin/amd/amd/amd.c
+++ b/usr.sbin/amd/amd/amd.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)amd.c 8.1 (Berkeley) 6/6/93
- * $Id: amd.c,v 1.6 2002/05/29 18:39:00 deraadt Exp $
+ * $Id: amd.c,v 1.7 2002/06/11 05:29:54 itojun Exp $
*/
#ifndef lint
@@ -323,7 +323,7 @@ char *argv[];
#endif /* DEBUG */
ppid = daemon_mode();
- sprintf(pid_fsname, "%s:(pid%ld)", hostname, (long)mypid);
+ snprintf(pid_fsname, sizeof(pid_fsname), "%s:(pid%ld)", hostname, (long)mypid);
do_mapc_reload = clocktime() + ONE_HOUR;
diff --git a/usr.sbin/amd/amd/amq_subr.c b/usr.sbin/amd/amd/amq_subr.c
index 2c15f2bd161..6c368a8a29a 100644
--- a/usr.sbin/amd/amd/amq_subr.c
+++ b/usr.sbin/amd/amd/amq_subr.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)amq_subr.c 8.1 (Berkeley) 6/6/93
- * $Id: amq_subr.c,v 1.5 2000/11/10 15:33:13 provos Exp $
+ * $Id: amq_subr.c,v 1.6 2002/06/11 05:29:54 itojun Exp $
*/
/*
@@ -189,7 +189,7 @@ struct svc_req *rqstp;
sin->sin_addr.s_addr == myipaddr.s_addr)) {
char dq[20];
plog(XLOG_INFO, "AMQ request from %s.%d DENIED",
- inet_dquad(dq, sin->sin_addr.s_addr),
+ inet_dquad(dq, sizeof(dq), sin->sin_addr.s_addr),
ntohs(sin->sin_port));
return(0);
}
diff --git a/usr.sbin/amd/amd/host_ops.c b/usr.sbin/amd/amd/host_ops.c
index 6d947742c0a..c1db515f292 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.5 2002/06/10 21:07:14 itojun Exp $ */
+/* $OpenBSD: host_ops.c,v 1.6 2002/06/11 05:29:54 itojun Exp $ */
/*
* Copyright (c) 1990 Jan-Simon Pendry
@@ -74,7 +74,7 @@
if (strcmp((ex)->ex_dir, "/") == 0) \
strcpy((mntpt), (mf)->mf_mount); \
else \
- sprintf((mntpt), "%s%s", (mf)->mf_mount, (ex)->ex_dir); \
+ snprintf((mntpt), sizeof(mntpt), "%s%s", (mf)->mf_mount, (ex)->ex_dir); \
}
/*
diff --git a/usr.sbin/amd/amd/info_hes.c b/usr.sbin/amd/amd/info_hes.c
index ef36b9f2e6f..28363b8aa4e 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.6 2002/06/10 21:07:14 itojun Exp $
+ * $Id: info_hes.c,v 1.7 2002/06/11 05:29:54 itojun Exp $
*/
/*
@@ -98,7 +98,7 @@ time_t *tp;
* call to hes_resolve("/defaults", "home.automount");
*/
#ifdef notdef
-#define MAKE_HES_NAME(dest, src) sprintf(dest, "%s%s", src + HES_PREFLEN, ".automount")
+#define MAKE_HES_NAME(dest, src) snprintf(dest, sizeof(dest), "%s%s", src + HES_PREFLEN, ".automount")
#endif
/*
@@ -120,7 +120,7 @@ time_t *tp;
dlog("hesiod_search(m=%x, map=%s, key=%s, pval=%x tp=%x)", m, map, key, pval, tp);
#endif
/*MAKE_HES_NAME(hes_map, map);*/
- sprintf(hes_key, "%s.%s", key, map+HES_PREFLEN);
+ snprintf(hes_key, sizeof(hes_key), "%s.%s", key, map+HES_PREFLEN);
/*
* Call the resolver
@@ -435,7 +435,7 @@ char *msg, *eom;
if (hp->rcode != NOERROR || hp->opcode != QUERY) {
char dq[20];
#ifdef DEBUG
- dlog("Bad response (%d) from nameserver %s", hp->rcode, inet_dquad(dq, hs_server_addr(servernum)->s_addr));
+ dlog("Bad response (%d) from nameserver %s", hp->rcode, inet_dquad(dq, sizeof(dq), hs_server_addr(servernum)->s_addr));
#endif /* DEBUG */
return(-1);
}
@@ -586,7 +586,7 @@ struct in_addr *addr;
char dq[20];
bcopy((char *)addr, nsaddr_list[hs_nscount++], sizeof(struct in_addr));
#ifdef DEBUG
- dlog("Adding NS address %s", inet_dquad(dq, addr->s_addr));
+ dlog("Adding NS address %s", inet_dquad(dq, sizeof(dq), addr->s_addr));
#endif /* DEBUG */
}
diff --git a/usr.sbin/amd/amd/info_passwd.c b/usr.sbin/amd/amd/info_passwd.c
index b1852776d19..ae216afc4a2 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.2 2002/06/10 21:07:14 itojun Exp $
+ * $Id: info_passwd.c,v 1.3 2002/06/11 05:29:54 itojun Exp $
*/
/*
@@ -143,7 +143,7 @@ time_t *tp;
q = strchr(rhost, '.');
if (q)
*q = '\0';
- sprintf(val, "rfs:=%s/%s;rhost:=%s;sublink:=%s;fs:=${autodir}%s",
+ snprintf(val, sizeof(val), "rfs:=%s/%s;rhost:=%s;sublink:=%s;fs:=${autodir}%s",
dir, rhost, rhost, user, pw->pw_dir);
if (q)
*q = '.';
diff --git a/usr.sbin/amd/amd/info_union.c b/usr.sbin/amd/amd/info_union.c
index b0311a2e3f1..f06d19ad772 100644
--- a/usr.sbin/amd/amd/info_union.c
+++ b/usr.sbin/amd/amd/info_union.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)info_union.c 8.1 (Berkeley) 6/6/93
- * $Id: info_union.c,v 1.2 2001/03/02 06:22:02 deraadt Exp $
+ * $Id: info_union.c,v 1.3 2002/06/11 05:29:54 itojun Exp $
*/
/*
@@ -87,7 +87,7 @@ time_t *tp;
for (p = v; p[1]; p++)
;
*pval = xmalloc(strlen(*p) + 5);
- sprintf(*pval, "fs:=%s", *p);
+ snprintf(*pval, strlen(*p) + 5, "fs:=%s", *p);
free(mapd);
free(v);
return 0;
@@ -131,7 +131,7 @@ void (*fn)();
dlog("... gives %s", dp->d_name);
#endif
val = xmalloc(dlen + 5);
- sprintf(val, "fs:=%s", *dir);
+ snprintf(val, dlen + 5, "fs:=%s", *dir);
(*fn)(m, strdup(dp->d_name), val);
}
closedir(dirp);
@@ -140,7 +140,7 @@ void (*fn)();
* Add wildcard entry
*/
{ char *val = xmalloc(strlen(dir[-1]) + 5);
- sprintf(val, "fs:=%s", dir[-1]);
+ snprintf(val, strlen(dir[-1]) + 5, "fs:=%s", dir[-1]);
(*fn)(m, strdup("*"), val);
}
free(mapd);
diff --git a/usr.sbin/amd/amd/mapc.c b/usr.sbin/amd/amd/mapc.c
index aeeb4a360a6..32fa7e2acbd 100644
--- a/usr.sbin/amd/amd/mapc.c
+++ b/usr.sbin/amd/amd/mapc.c
@@ -38,7 +38,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)mapc.c 8.1 (Berkeley) 6/6/93";*/
-static char *rcsid = "$Id: mapc.c,v 1.3 2002/05/29 18:39:00 deraadt Exp $";
+static char *rcsid = "$Id: mapc.c,v 1.4 2002/06/11 05:29:54 itojun Exp $";
#endif /* not lint */
/*
@@ -316,7 +316,7 @@ char *val;
/*
* Make sure the string is bound to the start and end
*/
- sprintf(keyb, "^%s$", key);
+ snprintf(keyb, sizeof(keyb), "^%s$", key);
re = regcomp(keyb);
if (re == 0) {
plog(XLOG_USER, "error compiling RE \"%s\": %s", keyb, reg_error);
@@ -818,7 +818,7 @@ char *map;
*/
dir = strdup(dir);
if (map)
- sprintf(str, "cache:=mapdefault;type:=toplvl;fs:=\"%s\";%s",
+ snprintf(str, sizeof(str), "cache:=mapdefault;type:=toplvl;fs:=\"%s\";%s",
map, opts ? opts : "");
else
strcpy(str, opts);
diff --git a/usr.sbin/amd/amd/mount_fs.c b/usr.sbin/amd/amd/mount_fs.c
index 9fd42107319..d40d9ce46df 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.6 2002/06/10 21:07:14 itojun Exp $
+ * $Id: mount_fs.c,v 1.7 2002/06/11 05:29:54 itojun Exp $
*/
#include "am.h"
@@ -174,11 +174,13 @@ again:
xopts = mnt->mnt_opts;
if (sizeof(stb.st_dev) == 2) {
/* e.g. SunOS 4.1 */
- sprintf(zopts, "%s,%s=%s%04x", xopts, MNTINFO_DEV,
+ snprintf(zopts, strlen(mnt->mnt_opts) + 32,
+ "%s,%s=%s%04x", xopts, MNTINFO_DEV,
MNTINFO_PREF, (u_int) stb.st_dev & 0xffff);
} else {
/* e.g. System Vr4 */
- sprintf(zopts, "%s,%s=%s%08x", xopts, MNTINFO_DEV,
+ snprintf(zopts, strlen(mnt->mnt_opts) + 32,
+ "%s,%s=%s%08x", xopts, MNTINFO_DEV,
MNTINFO_PREF, (u_int) stb.st_dev);
}
mnt->mnt_opts = zopts;
diff --git a/usr.sbin/amd/amd/nfs_ops.c b/usr.sbin/amd/amd/nfs_ops.c
index 3c80be1524a..e362a7657de 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.11 2002/06/10 21:07:14 itojun Exp $ */
+/* $OpenBSD: nfs_ops.c,v 1.12 2002/06/11 05:29:54 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.11 2002/06/10 21:07:14 itojun Exp $";
+static char *rcsid = "$OpenBSD: nfs_ops.c,v 1.12 2002/06/11 05:29:54 itojun Exp $";
#endif /* not lint */
#include "am.h"
@@ -438,7 +438,8 @@ am_opts *fo;
* Determine magic cookie to put in mtab
*/
xmtab = (char *) xmalloc(strlen(fo->opt_rhost) + strlen(fo->opt_rfs) + 2);
- sprintf(xmtab, "%s:%s", fo->opt_rhost, fo->opt_rfs);
+ snprintf(xmtab, strlen(fo->opt_rhost) + strlen(fo->opt_rfs) + 2,
+ "%s:%s", fo->opt_rhost, fo->opt_rfs);
#ifdef DEBUG
dlog("NFS: mounting remote server \"%s\", remote fs \"%s\" on \"%s\"",
fo->opt_rhost, fo->opt_rfs, fo->opt_fs);
diff --git a/usr.sbin/amd/amd/opts.c b/usr.sbin/amd/amd/opts.c
index 55f19d526d1..bea273124d3 100644
--- a/usr.sbin/amd/amd/opts.c
+++ b/usr.sbin/amd/amd/opts.c
@@ -38,7 +38,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)opts.c 8.1 (Berkeley) 6/6/93";*/
-static char *rcsid = "$Id: opts.c,v 1.2 2001/03/02 06:22:04 deraadt Exp $";
+static char *rcsid = "$Id: opts.c,v 1.3 2002/06/11 05:29:54 itojun Exp $";
#endif /* not lint */
#include "am.h"
@@ -520,7 +520,7 @@ static char expand_error[] = "No space to expand \"%s\"";
/*
* Copy the string across unexpanded
*/
- sprintf(xbuf, "${%s%s%s}",
+ snprintf(xbuf, sizeof(xbuf), "${%s%s%s}",
todo == E_File ? "/" :
todo == E_Domain ? "." : "",
nbuf,
diff --git a/usr.sbin/amd/amd/rpc_fwd.c b/usr.sbin/amd/amd/rpc_fwd.c
index 57826a1e36e..e92286377bc 100644
--- a/usr.sbin/amd/amd/rpc_fwd.c
+++ b/usr.sbin/amd/amd/rpc_fwd.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)rpc_fwd.c 8.1 (Berkeley) 6/6/93
- * $Id: rpc_fwd.c,v 1.1 1995/10/18 08:47:12 deraadt Exp $
+ * $Id: rpc_fwd.c,v 1.2 2002/06/11 05:29:54 itojun Exp $
*/
/*
@@ -292,7 +292,7 @@ fwd_fun cb;
*/
#ifdef DEBUG
{ char dq[20];
- dlog("Sending packet id %#x to %s.%d", p->rf_xid, inet_dquad(dq, fwdto->sin_addr.s_addr), ntohs(fwdto->sin_port));
+ dlog("Sending packet id %#x to %s.%d", p->rf_xid, inet_dquad(dq, sizeof(dq), fwdto->sin_addr.s_addr), ntohs(fwdto->sin_port));
}
#endif /* DEBUG */
if (sendto(fwd_sock, (char *) pkt, len, 0,
diff --git a/usr.sbin/amd/amd/util.c b/usr.sbin/amd/amd/util.c
index 48946e61e94..837616f83ed 100644
--- a/usr.sbin/amd/amd/util.c
+++ b/usr.sbin/amd/amd/util.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)util.c 8.1 (Berkeley) 6/6/93
- * $Id: util.c,v 1.5 2002/05/26 02:49:50 deraadt Exp $
+ * $Id: util.c,v 1.6 2002/06/11 05:29:54 itojun Exp $
*/
/*
@@ -243,13 +243,14 @@ char **chp;
* addr is in network byte order.
* sizeof(buf) needs to be at least 16.
*/
-char *inet_dquad P((char *buf, u_int32_t addr));
-char *inet_dquad(buf, addr)
+char *inet_dquad P((char *buf, size_t, u_int32_t addr));
+char *inet_dquad(buf, buflen, addr)
char *buf;
+size_t buflen;
u_int32_t addr;
{
addr = ntohl(addr);
- sprintf(buf, "%d.%d.%d.%d",
+ snprintf(buf, buflen, "%d.%d.%d.%d",
((addr >> 24) & 0xff),
((addr >> 16) & 0xff),
((addr >> 8) & 0xff),
diff --git a/usr.sbin/amd/amd/wire.c b/usr.sbin/amd/amd/wire.c
index 80a830b179b..6c0f0781d60 100644
--- a/usr.sbin/amd/amd/wire.c
+++ b/usr.sbin/amd/amd/wire.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)wire.c 8.1 (Berkeley) 6/6/93
- * $Id: wire.c,v 1.7 2001/03/02 06:22:05 deraadt Exp $
+ * $Id: wire.c,v 1.8 2002/06/11 05:29:54 itojun Exp $
*/
/*
@@ -236,7 +236,7 @@ char *getwire()
if (hp)
s = hp->h_name;
else
- s = inet_dquad(buf, subnet);
+ s = inet_dquad(buf, sizeof(buf), subnet);
}
netname = strdup(s);
}
@@ -275,7 +275,7 @@ u_int32_t addr;
#ifdef DEBUG
{ char buf[16];
- plog(XLOG_INFO, "%s is on a remote network", inet_dquad(buf, addr));
+ plog(XLOG_INFO, "%s is on a remote network", inet_dquad(buf, sizeof(buf), addr));
}
#endif
return FALSE;
diff --git a/usr.sbin/amd/fsinfo/fsi_analyze.c b/usr.sbin/amd/fsinfo/fsi_analyze.c
index e0becb3dfbb..545eaae7243 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.2 2002/06/10 21:07:14 itojun Exp $
+ * $Id: fsi_analyze.c,v 1.3 2002/06/11 05:29:55 itojun Exp $
*/
/*
@@ -222,7 +222,7 @@ disk_fs *dk;
log("Mount %s:", mp->m_name);
if (parent) {
char n[MAXPATHLEN];
- sprintf(n, "%s/%s", parent->m_name, mp->m_name);
+ snprintf(n, sizeof(n), "%s/%s", parent->m_name, mp->m_name);
if (*mp->m_name == '/')
lerror(mp->m_ioloc, "sub-directory %s of %s starts with '/'", mp->m_name, parent->m_name);
else if (STREQ(mp->m_name, "default"))
@@ -282,7 +282,7 @@ qelem *q;
if (STREQ(mp2->m_name, "default")) {
if (ISSET(mp2->m_mask, DM_VOLNAME)) {
char nbuf[1024];
- compute_automount_point(nbuf, dk->d_host, mp2->m_volname);
+ compute_automount_point(nbuf, sizeof(nbuf), dk->d_host, mp2->m_volname);
free(mp2->m_name);
mp2->m_name = strdup(nbuf);
log("%s:%s has default mount on %s", dk->d_host->h_hostname, dk->d_dev, mp2->m_name);
@@ -609,7 +609,7 @@ int lvl;
if (lvl > 0 || ap->a_mount)
if (ap->a_name[1] && strchr(ap->a_name+1, '/'))
lerror(ap->a_ioloc, "not allowed '/' in a directory name");
- sprintf(nname, "%s/%s", pref, ap->a_name);
+ snprintf(nname, sizeof(nname), "%s/%s", pref, ap->a_name);
free(ap->a_name);
ap->a_name = strdup(nname[1] == '/' ? nname+1 : nname);
log("automount point %s:", ap->a_name);
diff --git a/usr.sbin/amd/fsinfo/fsi_util.c b/usr.sbin/amd/fsinfo/fsi_util.c
index 32258a97326..13e5466227e 100644
--- a/usr.sbin/amd/fsinfo/fsi_util.c
+++ b/usr.sbin/amd/fsinfo/fsi_util.c
@@ -33,7 +33,7 @@
* SUCH DAMAGE.
*
* from: @(#)fsi_util.c 8.1 (Berkeley) 6/6/93
- * $Id: fsi_util.c,v 1.5 2001/01/02 20:01:35 mickey Exp $
+ * $Id: fsi_util.c,v 1.6 2002/06/11 05:29:55 itojun Exp $
*/
#include "../fsinfo/fsinfo.h"
@@ -168,7 +168,7 @@ static void show_total()
int len;
if (total_mmm < 0)
fputc('*', stdout);
- sprintf(n, "%d", total_shown);
+ snprintf(n, sizeof(n), "%d", total_shown);
len = strlen(n);
if (col_output(len))
fputc(' ', stdout);
@@ -247,7 +247,7 @@ char *arg;
{
char p[MAXPATHLEN];
FILE *ef;
- sprintf(p, "%s%s", pref, hn);
+ snprintf(p, sizeof(p), "%s%s", pref, hn);
log("Writing %s info for %s to %s", pref, hn, p);
ef = fopen(p, "w");
if (ef) {
@@ -269,15 +269,16 @@ FILE *fp;
/*
* Determine where Amd would automount the host/volname pair
*/
-void compute_automount_point(buf, hp, vn)
+void compute_automount_point(buf, buflen, hp, vn)
char *buf;
+size_t buflen;
host *hp;
char *vn;
{
#ifdef AMD_USES_HOSTPATH
- sprintf(buf, "%s/%s%s", autodir, hp->h_hostpath, vn);
+ snprintf(buf, buflen, "%s/%s%s", autodir, hp->h_hostpath, vn);
#else
- sprintf(buf, "%s/%s%s", autodir, hp->h_lochost, vn);
+ snprintf(buf, buflen, "%s/%s%s", autodir, hp->h_lochost, vn);
#endif
}
diff --git a/usr.sbin/amd/fsinfo/wr_atab.c b/usr.sbin/amd/fsinfo/wr_atab.c
index 15ca7f0cf99..d2843487e40 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.2 2002/06/10 21:07:14 itojun Exp $
+ * $Id: wr_atab.c,v 1.3 2002/06/11 05:29:55 itojun Exp $
*/
#include "../fsinfo/fsinfo.h"
@@ -96,7 +96,7 @@ int sk;
*/
if (mp->m_dk->d_host->h_lochost) {
char amountpt[1024];
- compute_automount_point(amountpt, mp->m_dk->d_host, mp->m_exported->m_volname);
+ compute_automount_point(amountpt, sizeof(amountpt), mp->m_dk->d_host, mp->m_exported->m_volname);
if (strcmp(mp->m_dk->d_mountpt, amountpt) != 0) {
/*
* ap->a_volname is the name of the aliased volume
diff --git a/usr.sbin/amd/include/am.h b/usr.sbin/amd/include/am.h
index 56952692865..fc5c26c25b7 100644
--- a/usr.sbin/amd/include/am.h
+++ b/usr.sbin/amd/include/am.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: am.h,v 1.4 2002/05/26 02:49:50 deraadt Exp $ */
+/* $OpenBSD: am.h,v 1.5 2002/06/11 05:29:55 itojun Exp $ */
/*
* Copyright (c) 1990 Jan-Simon Pendry
@@ -259,7 +259,7 @@ extern char *hasmntopt P((struct mntent*, char*));
#endif /* NEED_MNTOPT_PARSER */
extern int hasmntval P((struct mntent*, char*));
extern void host_normalize P((char **));
-extern char *inet_dquad P((char*, u_int32_t));
+extern char *inet_dquad P((char*, size_t, u_int32_t));
extern void init_map P((am_node*, char*));
extern void insert_am P((am_node*, am_node*));
extern void ins_que P((qelem*, qelem*));
diff --git a/usr.sbin/amd/mk-amd-map/mk-amd-map.c b/usr.sbin/amd/mk-amd-map/mk-amd-map.c
index 0333f41ea7d..55ffbaa7d4f 100644
--- a/usr.sbin/amd/mk-amd-map/mk-amd-map.c
+++ b/usr.sbin/amd/mk-amd-map/mk-amd-map.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)mk-amd-map.c 8.1 (Berkeley) 6/28/93
- * $Id: mk-amd-map.c,v 1.3 1997/04/04 18:41:42 deraadt Exp $
+ * $Id: mk-amd-map.c,v 1.4 2002/06/11 05:29:55 itojun Exp $
*/
/*
@@ -52,7 +52,7 @@ char copyright[] = "\
#endif /* not lint */
#ifndef lint
-static char rcsid[] = "$Id: mk-amd-map.c,v 1.3 1997/04/04 18:41:42 deraadt Exp $";
+static char rcsid[] = "$Id: mk-amd-map.c,v 1.4 2002/06/11 05:29:55 itojun Exp $";
static char sccsid[] = "@(#)mk-amd-map.c 8.1 (Berkeley) 6/28/93";
#endif /* not lint */
@@ -284,7 +284,7 @@ char *argv[];
exit(1);
}
mktemp(maptmp);
- sprintf(maptpag, "%s%s", maptmp, DBM_SUFFIX);
+ snprintf(maptpag, sizeof(maptpag), "%s%s", maptmp, DBM_SUFFIX);
if (remove_file(maptpag) < 0) {
fprintf(stderr, "Can't remove existing temporary file");
perror(maptpag);
@@ -298,8 +298,8 @@ char *argv[];
exit(1);
}
mktemp(maptmp);
- sprintf(maptpag, "%s.pag", maptmp);
- sprintf(maptdir, "%s.dir", maptmp);
+ snprintf(maptpag, sizeof(maptpag), "%s.pag", maptmp);
+ snprintf(maptdir, sizeof(maptdir), "%s.dir", maptmp);
if (remove_file(maptpag) < 0 || remove_file(maptdir) < 0) {
fprintf(stderr, "Can't remove existing temporary files; %s and", maptpag);
perror(maptdir);
@@ -334,7 +334,7 @@ char *argv[];
rc = 1;
} else {
#ifdef USING_DB
- sprintf(mappag, "%s%s", map, DBM_SUFFIX);
+ snprintf(mappag, sizeof(mappag), "%s%s", map, DBM_SUFFIX);
if (rename(maptpag, mappag) < 0) {
fprintf(stderr, "Couldn't rename %s to ", maptpag);
perror(mappag);
@@ -343,8 +343,8 @@ char *argv[];
rc = 1;
}
#else
- sprintf(mappag, "%s.pag", map);
- sprintf(mapdir, "%s.dir", map);
+ snprintf(mappag, sizeof(mappag), "%s.pag", map);
+ snprintf(mapdir, sizeof(mapdir), "%s.dir", map);
if (rename(maptpag, mappag) < 0) {
fprintf(stderr, "Couldn't rename %s to ", maptpag);
perror(mappag);