diff mbox series

[iproute2] tc: m_action: check cookie hex string len

Message ID 20200427061055.4058-1-jiri@resnulli.us
State New
Headers show
Series [iproute2] tc: m_action: check cookie hex string len | expand

Commit Message

Jiri Pirko April 27, 2020, 6:10 a.m. UTC
From: Jiri Pirko <jiri@mellanox.com>

Check the cookie hex string len is dividable by 2 as the valid hex
string always should be.

Reported-by: Alex Kushnarov <alexanderk@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 tc/m_action.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tc/m_action.c b/tc/m_action.c
index 108329db29d0..b41782de9a02 100644
--- a/tc/m_action.c
+++ b/tc/m_action.c
@@ -291,7 +291,8 @@  done0:
 					invarg(cookie_err_m, *argv);
 				}
 
-				if (hex2mem(*argv, act_ck, slen / 2) < 0)
+				if (slen % 2 ||
+				    hex2mem(*argv, act_ck, slen / 2) < 0)
 					invarg("cookie must be a hex string\n",
 					       *argv);