dpdk/0187-telemetry-limit-command-characters.patch
Huisong Li 7d8194517a sig-dpdk: sync some patches for PMD/LIB/APP
Sync some patches for hns3 PMD, telemetry and testpmd. And main
modifications are as follows:
 - backport some bugfixes for hns3
 - revert Tx performance optimization for hns3
 - add Rx/Tx descriptor dump feature for hns3
 - refactor some RSS commands for testpmd
 - add ethdev telemetry private dump
 - add dmadev telemetry
 - sync telemetry lib

Signed-off-by: Huisong Li <lihuisong@huawei.com>
(cherry picked from commit 4f06d27eff9aa99c2e2073ac74328893990ed8ed)
2022-10-24 16:11:45 +08:00

56 lines
1.6 KiB
Diff

From 585eeea3522ce2225a1df94fcc0b8aec2d881b44 Mon Sep 17 00:00:00 2001
From: Bruce Richardson <bruce.richardson@intel.com>
Date: Fri, 21 Oct 2022 15:37:03 +0800
Subject: [PATCH 187/189] telemetry: limit command characters
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Limit the telemetry command characters to the minimum set needed for
current implementations. This prevents issues with invalid json
characters needing to be escaped on replies.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
lib/telemetry/telemetry.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index d4a7838ded..f0be50b2bf 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -3,6 +3,7 @@
*/
#ifndef RTE_EXEC_ENV_WINDOWS
+#include <ctype.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/socket.h>
@@ -71,12 +72,19 @@ int
rte_telemetry_register_cmd(const char *cmd, telemetry_cb fn, const char *help)
{
struct cmd_callback *new_callbacks;
+ const char *cmdp = cmd;
int i = 0;
if (strlen(cmd) >= MAX_CMD_LEN || fn == NULL || cmd[0] != '/'
|| strlen(help) >= RTE_TEL_MAX_STRING_LEN)
return -EINVAL;
+ while (*cmdp != '\0') {
+ if (!isalnum(*cmdp) && *cmdp != '_' && *cmdp != '/')
+ return -EINVAL;
+ cmdp++;
+ }
+
rte_spinlock_lock(&callback_sl);
new_callbacks = realloc(callbacks, sizeof(callbacks[0]) * (num_callbacks + 1));
if (new_callbacks == NULL) {
--
2.23.0