summaryrefslogtreecommitdiffstats
path: root/lib/libc/xdr
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1998-05-15 22:57:31 +0000
committerwpaul <wpaul@FreeBSD.org>1998-05-15 22:57:31 +0000
commit4851695cf70c307984b890a157551c5f9b1e7925 (patch)
treefd1707c911672e684309beb05f2153ec00d1bcf9 /lib/libc/xdr
parent22b36bc76e6cb62c9cd29f3f988060d80af834c8 (diff)
downloadFreeBSD-src-4851695cf70c307984b890a157551c5f9b1e7925.zip
FreeBSD-src-4851695cf70c307984b890a157551c5f9b1e7925.tar.gz
Patch RPC library to avoid possible denial of service attacks as described
recently in BUGTRAQ. The set_input_fragment() routine in the XDR record marking code blindly trusts that the first two bytes it sees will in fact be an actual record header and that the specified size will be sane. In fact, if you just telnet to a listening port of an RPC service and send a few carriage returns, set_input_fragment() will obtain a ridiculously large record size and sit there for a long time trying to read from the network. A sanity test is required: if the record size is larger than the receive buffer, punt.
Diffstat (limited to 'lib/libc/xdr')
-rw-r--r--lib/libc/xdr/xdr_rec.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/libc/xdr/xdr_rec.c b/lib/libc/xdr/xdr_rec.c
index f54172b..2919e28 100644
--- a/lib/libc/xdr/xdr_rec.c
+++ b/lib/libc/xdr/xdr_rec.c
@@ -29,7 +29,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)xdr_rec.c 2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$Id: xdr_rec.c,v 1.5 1996/12/30 14:07:10 peter Exp $";
+static char *rcsid = "$Id: xdr_rec.c,v 1.8 1997/05/28 04:57:38 wpaul Exp $";
#endif
/*
@@ -550,6 +550,12 @@ set_input_fragment(rstrm)
return (FALSE);
header = (long)ntohl(header);
rstrm->last_frag = ((header & LAST_FRAG) == 0) ? FALSE : TRUE;
+ /*
+ * Sanity check. Try not to accept wildly incorrect
+ * record sizes.
+ */
+ if ((header & (~LAST_FRAG)) > rstrm->recvsize)
+ return(FALSE);
rstrm->fbtbc = header & (~LAST_FRAG);
return (TRUE);
}
OpenPOWER on IntegriCloud