[dpdk-stable] [PATCH v2] usertools: replace unsafe input function

Andrius Sirvys andrius.sirvys at intel.com
Mon Apr 8 15:40:48 CEST 2019


LGTM static code analysis tool reports that the function 'input' is
unsafe. Changed to use raw_input which then converts it using
ast.literal_eval() which is safe.

Fixes: d1b94da4a4e0 ("usertools: add client script for telemetry")
Cc: ciara.power at intel.com

Signed-off-by: Andrius Sirvys <andrius.sirvys at intel.com>
Acked-by: Kevin Laatz <kevin.laatz at intel.com>
---
v2:raw_input doesn't exist in Python 3, added a clause
to check python version
---
 usertools/dpdk-telemetry-client.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/usertools/dpdk-telemetry-client.py b/usertools/dpdk-telemetry-client.py
index ce0c7a9..5f6c47b 100755
--- a/usertools/dpdk-telemetry-client.py
+++ b/usertools/dpdk-telemetry-client.py
@@ -14,6 +14,11 @@
 API_UNREG = "{\"action\":2,\"command\":\"clients\",\"data\":{\"client_path\":\""
 DEFAULT_FP = "/var/run/dpdk/default_client"
 
+try:
+	raw_input # Python 2
+except NameError:
+	raw_input = input # Python 3
+
 class Socket:
 
     def __init__(self):
-- 
2.7.4



More information about the stable mailing list