diff options
author | brian <brian@FreeBSD.org> | 1999-08-06 13:53:03 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1999-08-06 13:53:03 +0000 |
commit | 29c67703e3751c283a1bdfe7764effe015c13b83 (patch) | |
tree | ef1e40a5b9d87f3d7f7d7336ae7dc5a534520d3d /sys/net/if_tun.c | |
parent | df1c1756e31202c817f6c35422ebc847da176a0a (diff) | |
download | FreeBSD-src-29c67703e3751c283a1bdfe7764effe015c13b83.zip FreeBSD-src-29c67703e3751c283a1bdfe7764effe015c13b83.tar.gz |
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
Diffstat (limited to 'sys/net/if_tun.c')
-rw-r--r-- | sys/net/if_tun.c | 11 |
1 files changed, 8 insertions, 3 deletions
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; |