summaryrefslogtreecommitdiffstats
path: root/usr.sbin/tcpdump/print-sunrpc.c
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2001-11-07 18:48:16 +0000
committerderaadt <deraadt@openbsd.org>2001-11-07 18:48:16 +0000
commit9f840a032a88dde66ea8f79aaeeba45bc86e04ca (patch)
treec9105e6f57b0e6abcaa5129574ba304aa47b8795 /usr.sbin/tcpdump/print-sunrpc.c
parentavoid buffer overflows. when will people learn to use snprintf correctly (diff)
downloadwireguard-openbsd-9f840a032a88dde66ea8f79aaeeba45bc86e04ca.tar.xz
wireguard-openbsd-9f840a032a88dde66ea8f79aaeeba45bc86e04ca.zip
simplify buffer handling; ok ho
Diffstat (limited to 'usr.sbin/tcpdump/print-sunrpc.c')
-rw-r--r--usr.sbin/tcpdump/print-sunrpc.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/usr.sbin/tcpdump/print-sunrpc.c b/usr.sbin/tcpdump/print-sunrpc.c
index 6d9b13e67ae..4235caed153 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.11 2001/11/06 03:11:40 deraadt Exp $ */
+/* $OpenBSD: print-sunrpc.c,v 1.12 2001/11/07 18:48:16 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993, 1994, 1995, 1996
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /home/cvs/src/usr.sbin/tcpdump/print-sunrpc.c,v 1.11 2001/11/06 03:11:40 deraadt Exp $ (LBL)";
+ "@(#) $Header: /home/cvs/src/usr.sbin/tcpdump/print-sunrpc.c,v 1.12 2001/11/07 18:48:16 deraadt Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -115,10 +115,8 @@ progstr(prog)
return (buf);
rp = getrpcbynumber(prog);
if (rp == NULL)
- (void) snprintf(buf, sizeof(buf), "#%u", prog);
- else {
- strncpy(buf, rp->r_name, sizeof buf-1);
- buf[sizeof buf-1] = '\0';
- }
+ snprintf(buf, sizeof(buf), "#%u", prog);
+ else
+ strlcpy(buf, rp->r_name, sizeof(buf));
return (buf);
}