cxgbetool(8): Reject invalid VLAN values.

Submitted by:	Krishnamraju Eraparaju @ Chelsio
MFC after:	1 week
Sponsored by:	Chelsio Communications
This commit is contained in:
Navdeep Parhar 2018-06-26 21:56:06 +00:00
parent c907f24ead
commit 2293e22112
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=335680

View File

@ -1102,6 +1102,8 @@ del_filter(uint32_t idx, int hashfilter)
return doit(CHELSIO_T4_DEL_FILTER, &t);
}
#define MAX_VLANID (4095)
static int
set_filter(uint32_t idx, int argc, const char *argv[], int hash)
{
@ -1308,7 +1310,8 @@ set_filter(uint32_t idx, int argc, const char *argv[], int hash)
t.fs.newvlan == VLAN_INSERT) {
t.fs.vlan = strtoul(argv[start_arg + 1] + 1,
&p, 0);
if (p == argv[start_arg + 1] + 1 || p[0] != 0) {
if (p == argv[start_arg + 1] + 1 || p[0] != 0 ||
t.fs.vlan > MAX_VLANID) {
warnx("invalid vlan \"%s\"",
argv[start_arg + 1]);
return (EINVAL);