netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute] ip: validate vlan value for vlan info
@ 2017-12-15  2:19 Stephen Hemminger
  0 siblings, 0 replies; only message in thread
From: Stephen Hemminger @ 2017-12-15  2:19 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

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

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 ip/iplink.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ip/iplink.c b/ip/iplink.c
index e83f1477e7bc..1e685cc23805 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -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);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-12-15  2:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-15  2:19 [PATCH iproute] ip: validate vlan value for vlan info Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).