aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorBrian Somers <brian@FreeBSD.org>1999-05-14 09:35:51 +0000
committerBrian Somers <brian@FreeBSD.org>1999-05-14 09:35:51 +0000
commit76d9853864faeb3968112fa29bcec82bd8125276 (patch)
tree6b15d891d0e0a576b84ed5d103bc93225d27aa95 /usr.sbin
parent454a0546ba004396a91ded6b66d953587d6146e3 (diff)
downloadsrc-76d9853864faeb3968112fa29bcec82bd8125276.tar.gz
src-76d9853864faeb3968112fa29bcec82bd8125276.zip
Ensure that we're not going to overflow our ``struct tun''
when we mbuf_Read() into it. Add the link name to a few diagnostics.
Notes
Notes: svn path=/head/; revision=47168
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/ip.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c
index cc471a5b3989..f6acf858d6df 100644
--- a/usr.sbin/ppp/ip.c
+++ b/usr.sbin/ppp/ip.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ip.c,v 1.59 1999/05/08 11:06:42 brian Exp $
+ * $Id: ip.c,v 1.60 1999/05/09 20:02:19 brian Exp $
*
* TODO:
* o Return ICMP message for filterd packet
@@ -395,6 +395,12 @@ ip_Input(struct bundle *bundle, struct link *l, struct mbuf *bp)
tun_fill_header(tun, AF_INET);
nb = mbuf_Length(bp);
+ if (nb > sizeof tun.data) {
+ log_Printf(LogWARN, "ip_Input: %s: Packet too large (got %d, max %d)\n",
+ l->name, nb, (int)(sizeof tun.data));
+ mbuf_Free(bp);
+ return NULL;
+ }
mbuf_Read(bp, tun.data, nb);
if (PacketCheck(bundle, tun.data, nb, &bundle->filter.in) < 0)
@@ -410,9 +416,10 @@ ip_Input(struct bundle *bundle, struct link *l, struct mbuf *bp)
nw = write(bundle->dev.fd, &tun, nb);
if (nw != nb) {
if (nw == -1)
- log_Printf(LogERROR, "ip_Input: wrote %d, got %s\n", nb, strerror(errno));
+ log_Printf(LogERROR, "ip_Input: %s: wrote %d, got %s\n",
+ l->name, nb, strerror(errno));
else
- log_Printf(LogERROR, "ip_Input: wrote %d, got %d\n", nb, nw);
+ log_Printf(LogERROR, "ip_Input: %s: wrote %d, got %d\n", l->name, nb, nw);
}
return NULL;