summaryrefslogtreecommitdiffstats
path: root/sys/netipx
diff options
context:
space:
mode:
authorarchie <archie@FreeBSD.org>1998-12-04 22:54:57 +0000
committerarchie <archie@FreeBSD.org>1998-12-04 22:54:57 +0000
commit982e80577dd08945aa2345ebe35e3f50eef9eb48 (patch)
treee21ff4cbfbcb4097c6cc444d68ddd9a3fd37837f /sys/netipx
parent707b8f68aa118c7396f2a2633751e32477d9ed08 (diff)
downloadFreeBSD-src-982e80577dd08945aa2345ebe35e3f50eef9eb48.zip
FreeBSD-src-982e80577dd08945aa2345ebe35e3f50eef9eb48.tar.gz
Examine all occurrences of sprintf(), strcat(), and str[n]cpy()
for possible buffer overflow problems. Replaced most sprintf()'s with snprintf(); for others cases, added terminating NUL bytes where appropriate, replaced constants like "16" with sizeof(), etc. These changes include several bug fixes, but most changes are for maintainability's sake. Any instance where it wasn't "immediately obvious" that a buffer overflow could not occur was made safer. Reviewed by: Bruce Evans <bde@zeta.org.au> Reviewed by: Matthew Dillon <dillon@apollo.backplane.com> Reviewed by: Mike Spengler <mks@networkcs.com>
Diffstat (limited to 'sys/netipx')
-rw-r--r--sys/netipx/ipx.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/netipx/ipx.c b/sys/netipx/ipx.c
index ab2f42a..752c2dc 100644
--- a/sys/netipx/ipx.c
+++ b/sys/netipx/ipx.c
@@ -33,7 +33,7 @@
*
* @(#)ipx.c
*
- * $Id: ipx.c,v 1.11 1997/06/26 19:35:42 jhay Exp $
+ * $Id: ipx.c,v 1.12 1998/06/07 17:12:18 dfr Exp $
*/
#include <sys/param.h>
@@ -359,7 +359,7 @@ register struct ipx_addr *addr;
net = "*";
else {
q = work.x_net.c_net;
- sprintf(cnet, "%x%x%x%x",
+ snprintf(cnet, sizeof(cnet), "%x%x%x%x",
q[0], q[1], q[2], q[3]);
for (p = cnet; *p == '0' && p < cnet + 8; p++)
continue;
@@ -372,7 +372,7 @@ register struct ipx_addr *addr;
host = "*";
else {
q = work.x_host.c_host;
- sprintf(chost, "%x%x%x%x%x%x",
+ snprintf(chost, sizeof(chost), "%x%x%x%x%x%x",
q[0], q[1], q[2], q[3], q[4], q[5]);
for (p = chost; *p == '0' && p < chost + 12; p++)
continue;
@@ -382,9 +382,9 @@ register struct ipx_addr *addr;
if (port) {
if (strcmp(host, "*") == 0) {
host = "";
- sprintf(cport, "%x", port);
+ snprintf(cport, sizeof(cport), "%x", port);
} else
- sprintf(cport, ".%x", port);
+ snprintf(cport, sizeof(cport), ".%x", port);
} else
*cport = 0;
OpenPOWER on IntegriCloud