From 29c67703e3751c283a1bdfe7764effe015c13b83 Mon Sep 17 00:00:00 2001 From: brian Date: Fri, 6 Aug 1999 13:53:03 +0000 Subject: Define IF_MAXMTU and IF_MINMTU and don't allow MTUs with out-of-range values. ``comparison is always 0'' warnings are silly ! Ok'd by: wollman, dg Advised by: bde --- sys/net/if_tun.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'sys/net/if_tun.c') diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 16542de..3cb8f6b 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -302,9 +302,12 @@ tunifioctl(ifp, cmd, data) ifp->if_name, ifp->if_unit); break; case SIOCSIFMTU: - ifp->if_mtu = ifr->ifr_mtu; - TUNDEBUG("%s%d: mtu set\n", - ifp->if_name, ifp->if_unit); + if (ifr->ifr_mtu < IF_MINMTU || ifr->ifr_mtu > IF_MAXMTU) + error = EINVAL; + else { + ifp->if_mtu = ifr->ifr_mtu; + TUNDEBUG("%s%d: mtu set\n", ifp->if_name, ifp->if_unit); + } break; case SIOCADDMULTI: case SIOCDELMULTI: @@ -435,6 +438,8 @@ tunioctl(dev, cmd, data, flag, p) switch (cmd) { case TUNSIFINFO: tunp = (struct tuninfo *)data; + if (tunp->mtu < IF_MINMTU || tunp->mtu > IF_MAXMTU) + return (EINVAL); tp->tun_if.if_mtu = tunp->mtu; tp->tun_if.if_type = tunp->type; tp->tun_if.if_baudrate = tunp->baudrate; -- cgit v1.1