summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-11-06 03:11:41 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-11-06 03:11:41 +0000
commitae6af869059184f071b9cf98a62cdfbeb9459b25 (patch)
tree08478b1b2ac68b8a23edcda7dca0343cb6b40366 /usr.sbin
parent95ad5e3fd5480be62b7baba07cf74ec1fb46ba7e (diff)
a bit of snprintf cleaning
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/tcpdump/print-atalk.c6
-rw-r--r--usr.sbin/tcpdump/print-cnfp.c14
-rw-r--r--usr.sbin/tcpdump/print-decnet.c9
-rw-r--r--usr.sbin/tcpdump/print-ipx.c6
-rw-r--r--usr.sbin/tcpdump/print-snmp.c8
-rw-r--r--usr.sbin/tcpdump/print-sunrpc.c6
-rw-r--r--usr.sbin/tcpdump/util.c6
7 files changed, 30 insertions, 25 deletions
diff --git a/usr.sbin/tcpdump/print-atalk.c b/usr.sbin/tcpdump/print-atalk.c
index 7ea8fa68554..f8e545c1821 100644
--- a/usr.sbin/tcpdump/print-atalk.c
+++ b/usr.sbin/tcpdump/print-atalk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print-atalk.c,v 1.17 2001/10/30 12:30:04 ho Exp $ */
+/* $OpenBSD: print-atalk.c,v 1.18 2001/11/06 03:11:40 deraadt Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@@ -25,7 +25,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-atalk.c,v 1.17 2001/10/30 12:30:04 ho Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-atalk.c,v 1.18 2001/11/06 03:11:40 deraadt Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -640,7 +640,7 @@ ddpskt_string(register int skt)
static char buf[10];
if (nflag) {
- (void)sprintf(buf, "%d", skt);
+ (void)snprintf(buf, sizeof buf, "%d", skt);
return (buf);
}
return (tok2str(skt2str, "%d", skt));
diff --git a/usr.sbin/tcpdump/print-cnfp.c b/usr.sbin/tcpdump/print-cnfp.c
index 9bf2b59c87c..e2de4866f95 100644
--- a/usr.sbin/tcpdump/print-cnfp.c
+++ b/usr.sbin/tcpdump/print-cnfp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print-cnfp.c,v 1.3 2000/10/03 14:21:56 ho Exp $ */
+/* $OpenBSD: print-cnfp.c,v 1.4 2001/11/06 03:11:40 deraadt Exp $ */
/*
* Copyright (c) 1998 Michael Shalayeff
@@ -117,15 +117,19 @@ cnfp_print(register const u_char *cp, u_int len, register const u_char *bp)
asbuf[0] = buf[0] = '\0';
if (ver == 5) {
- sprintf(buf, "/%d", (ntohl(nr->masks) >> 24) & 0xff);
- sprintf(asbuf, "%d:", (ntohl(nr->asses) >> 16) & 0xffff);
+ snprintf(buf, sizeof buf, "/%d",
+ (ntohl(nr->masks) >> 24) & 0xff);
+ snprintf(asbuf, sizeof asbuf, "%d:",
+ (ntohl(nr->asses) >> 16) & 0xffff);
}
printf("\n %s%s%s:%u ", inet_ntoa(nr->src_ina), buf, asbuf,
ntohl(nr->ports) >> 16);
if (ver == 5) {
- sprintf(buf, "/%d", (ntohl(nr->masks) >> 16) & 0xff);
- sprintf(asbuf, "%d:", ntohl(nr->asses) & 0xffff);
+ snprintf(buf, sizeof buf, "/%d",
+ (ntohl(nr->masks) >> 16) & 0xff);
+ snprintf(asbuf, sizeof asbuf, "%d:",
+ ntohl(nr->asses) & 0xffff);
}
printf("> %s%s%s:%u ", inet_ntoa(nr->dst_ina), buf, asbuf,
ntohl(nr->ports) & 0xffff);
diff --git a/usr.sbin/tcpdump/print-decnet.c b/usr.sbin/tcpdump/print-decnet.c
index 54fa6f4f7ff..c7224a80268 100644
--- a/usr.sbin/tcpdump/print-decnet.c
+++ b/usr.sbin/tcpdump/print-decnet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print-decnet.c,v 1.8 2000/10/03 14:31:56 ho Exp $ */
+/* $OpenBSD: print-decnet.c,v 1.9 2001/11/06 03:11:40 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-decnet.c,v 1.8 2000/10/03 14:31:56 ho Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-decnet.c,v 1.9 2001/11/06 03:11:40 deraadt Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -737,11 +737,12 @@ dnnum_string(u_short dnaddr)
char *str;
int area = (u_short)(dnaddr & AREAMASK) >> AREASHIFT;
int node = dnaddr & NODEMASK;
+ int len = sizeof("00.0000");
- str = (char *)malloc(sizeof("00.0000"));
+ str = (char *)malloc(len);
if (str == NULL)
error("dnnum_string: malloc");
- sprintf(str, "%d.%d", area, node);
+ snprintf(str, len, "%d.%d", area, node);
return(str);
}
diff --git a/usr.sbin/tcpdump/print-ipx.c b/usr.sbin/tcpdump/print-ipx.c
index 1dc3e2b12b5..5b3208f55c8 100644
--- a/usr.sbin/tcpdump/print-ipx.c
+++ b/usr.sbin/tcpdump/print-ipx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print-ipx.c,v 1.7 2000/10/03 14:31:57 ho Exp $ */
+/* $OpenBSD: print-ipx.c,v 1.8 2001/11/06 03:11:40 deraadt Exp $ */
/*
* Copyright (c) 1994, 1995, 1996
@@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-ipx.c,v 1.7 2000/10/03 14:31:57 ho Exp $";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-ipx.c,v 1.8 2001/11/06 03:11:40 deraadt Exp $";
#endif
#include <sys/param.h>
@@ -90,7 +90,7 @@ ipxaddr_string(u_int32_t net, const u_char *node)
{
static char line[256];
- sprintf(line, "%x.%02x:%02x:%02x:%02x:%02x:%02x",
+ snprintf(line, sizeof(line), "%x.%02x:%02x:%02x:%02x:%02x:%02x",
net, node[0], node[1], node[2], node[3], node[4], node[5]);
return line;
diff --git a/usr.sbin/tcpdump/print-snmp.c b/usr.sbin/tcpdump/print-snmp.c
index a69ae668122..b5a65ed1479 100644
--- a/usr.sbin/tcpdump/print-snmp.c
+++ b/usr.sbin/tcpdump/print-snmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print-snmp.c,v 1.9 2001/08/11 22:26:39 jakob Exp $ */
+/* $OpenBSD: print-snmp.c,v 1.10 2001/11/06 03:11:40 deraadt Exp $ */
/*
* Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
@@ -57,7 +57,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-snmp.c,v 1.9 2001/08/11 22:26:39 jakob Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-snmp.c,v 1.10 2001/11/06 03:11:40 deraadt Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -149,7 +149,7 @@ char *ErrorStatus[] = {
};
#define DECODE_ErrorStatus(e) \
( e >= 0 && e <= sizeof(ErrorStatus)/sizeof(ErrorStatus[0]) \
- ? ErrorStatus[e] : (sprintf(errbuf, "err=%u", e), errbuf))
+ ? ErrorStatus[e] : (snprintf(errbuf, sizeof(errbuf), "err=%u", e), errbuf))
/*
* generic-trap values in the SNMP Trap-PDU
@@ -166,7 +166,7 @@ char *GenericTrap[] = {
};
#define DECODE_GenericTrap(t) \
( t >= 0 && t <= sizeof(GenericTrap)/sizeof(GenericTrap[0]) \
- ? GenericTrap[t] : (sprintf(buf, "gt=%d", t), buf))
+ ? GenericTrap[t] : (snprintf(buf, sizeof(buf), "gt=%d", t), buf))
/*
* ASN.1 type class table
diff --git a/usr.sbin/tcpdump/print-sunrpc.c b/usr.sbin/tcpdump/print-sunrpc.c
index 69d50df7108..859f72c3eeb 100644
--- a/usr.sbin/tcpdump/print-sunrpc.c
+++ b/usr.sbin/tcpdump/print-sunrpc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print-sunrpc.c,v 1.10 2000/12/05 08:17:45 jakob Exp $ */
+/* $OpenBSD: print-sunrpc.c,v 1.11 2001/11/06 03:11:40 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993, 1994, 1995, 1996
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-sunrpc.c,v 1.10 2000/12/05 08:17:45 jakob Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-sunrpc.c,v 1.11 2001/11/06 03:11:40 deraadt Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -115,7 +115,7 @@ progstr(prog)
return (buf);
rp = getrpcbynumber(prog);
if (rp == NULL)
- (void) sprintf(buf, "#%u", prog);
+ (void) snprintf(buf, sizeof(buf), "#%u", prog);
else {
strncpy(buf, rp->r_name, sizeof buf-1);
buf[sizeof buf-1] = '\0';
diff --git a/usr.sbin/tcpdump/util.c b/usr.sbin/tcpdump/util.c
index bdb4deef5ad..f510451870c 100644
--- a/usr.sbin/tcpdump/util.c
+++ b/usr.sbin/tcpdump/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.13 2001/10/02 18:04:36 deraadt Exp $ */
+/* $OpenBSD: util.c,v 1.14 2001/11/06 03:11:40 deraadt Exp $ */
/*
* Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/util.c,v 1.13 2001/10/02 18:04:36 deraadt Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/util.c,v 1.14 2001/11/06 03:11:40 deraadt Exp $ (LBL)";
#endif
#include <sys/types.h>
@@ -134,7 +134,7 @@ ts_print(register const struct bpf_timeval *tvp)
case -1:
/* Unix timeval style */
(void)printf("%u.%06u ",
- (u_int32_t)tvp->tv_sec, (u_int32_t)tvp->tv_usec);
+ (u_int32_t)tvp->tv_sec, (u_int32_t)tvp->tv_usec);
break;
case -2:
t=tvp->tv_sec;