summaryrefslogtreecommitdiff
path: root/usr.bin/systat/netstat.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/systat/netstat.c')
-rw-r--r--usr.bin/systat/netstat.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c
index b8be4936914e..1e587e9a0dc9 100644
--- a/usr.bin/systat/netstat.c
+++ b/usr.bin/systat/netstat.c
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)netstat.c 8.1 (Berkeley) 6/6/93";
*/
static const char rcsid[] =
- "$Id$";
+ "$Id: netstat.c,v 1.8 1997/02/22 19:57:16 peter Exp $";
#endif /* not lint */
/*
@@ -372,14 +372,16 @@ inetprint(in, port, proto)
struct servent *sp = 0;
char line[80], *cp, *index();
- sprintf(line, "%.*s.", 16, inetname(*in));
+ snprintf(line, sizeof(line), "%.*s.", 16, inetname(*in));
cp = index(line, '\0');
if (!nflag && port)
sp = getservbyport(port, proto);
if (sp || port == 0)
- sprintf(cp, "%.8s", sp ? sp->s_name : "*");
+ snprintf(cp, sizeof(line) - (cp - line), "%.8s",
+ sp ? sp->s_name : "*");
else
- sprintf(cp, "%d", ntohs((u_short)port));
+ snprintf(cp, sizeof(line) - (cp - line), "%d",
+ ntohs((u_short)port));
/* pad to full column to clear any garbage */
cp = index(line, '\0');
while (cp - line < 22)
@@ -420,11 +422,11 @@ inetname(in)
if (in.s_addr == INADDR_ANY)
strcpy(line, "*");
else if (cp)
- strcpy(line, cp);
+ snprintf(line, sizeof(line), "%s", cp);
else {
in.s_addr = ntohl(in.s_addr);
#define C(x) ((x) & 0xff)
- sprintf(line, "%u.%u.%u.%u", C(in.s_addr >> 24),
+ snprintf(line, sizeof(line), "%u.%u.%u.%u", C(in.s_addr >> 24),
C(in.s_addr >> 16), C(in.s_addr >> 8), C(in.s_addr));
}
return (line);