Skip to contentSkip to conversation

ip: validate vlan value for vlan info

PATCH New Stephen Hemminger 1 participant 1 message Dec 15, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ip: validate vlan value for vlan info

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

---
 ip/iplink.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
ip/iplink.c +3 -1
index e83f1477e7bc..1e685cc23805 100644
@@ -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);
Signature · 1 line
2.11.0