ip: validate vlan value for vlan info

The VLAN tag must be 0..4095 to be valid.
Better to trap it here.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
Stephen Hemminger 2017-12-14 18:17:43 -08:00
parent a6addd5cdc
commit ae8e1cb83b
1 changed files with 3 additions and 1 deletions

View File

@ -276,11 +276,13 @@ static void iplink_parse_vf_vlan_info(int vf, int *argcp, char ***argvp,
{
int argc = *argcp;
char **argv = *argvp;
unsigned int vci;
NEXT_ARG();
if (get_unsigned(&ivvip->vlan, *argv, 0))
if (get_unsigned(&vci, *argv, 0) || vci > 4095)
invarg("Invalid \"vlan\" value\n", *argv);
ivvip->vlan = vci;
ivvip->vf = vf;
ivvip->qos = 0;
ivvip->vlan_proto = htons(ETH_P_8021Q);