代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/dpdk 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From c3036c497f29f4acf6423a88f59963781af3eafd Mon Sep 17 00:00:00 2001
From: Bruce Richardson <bruce.richardson@intel.com>
Date: Fri, 21 Oct 2022 15:37:02 +0800
Subject: [PATCH 186/189] telemetry: add escaping of strings in dicts
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When strings are added to an dict variable, we need to properly escape
the invalid json characters in the strings.
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_json.h | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h
index c4442a0bf0..e3fae7c30d 100644
--- a/lib/telemetry/telemetry_json.h
+++ b/lib/telemetry/telemetry_json.h
@@ -54,7 +54,7 @@ static const char control_chars[0x20] = {
* @internal
* This function acts the same as __json_snprintf(buf, len, "%s%s%s", prefix, str, suffix)
* except that it does proper escaping of "str" as necessary. Prefix and suffix should be compile-
- * time constants not needing escaping.
+ * time constants, or values not needing escaping.
* Drops any invalid characters we don't support
*/
static inline int
@@ -219,12 +219,16 @@ static inline int
rte_tel_json_add_obj_str(char *buf, const int len, const int used,
const char *name, const char *val)
{
+ char tmp_name[RTE_TEL_MAX_STRING_LEN + 5];
int ret, end = used - 1;
+
+ /* names are limited to certain characters so need no escaping */
+ snprintf(tmp_name, sizeof(tmp_name), "{\"%s\":\"", name);
if (used <= 2) /* assume empty, since minimum is '{}' */
- return __json_snprintf(buf, len, "{\"%s\":\"%s\"}", name, val);
+ return __json_format_str(buf, len, tmp_name, val, "\"}");
- ret = __json_snprintf(buf + end, len - end, ",\"%s\":\"%s\"}",
- name, val);
+ tmp_name[0] = ','; /* replace '{' with ',' at start */
+ ret = __json_format_str(buf + end, len - end, tmp_name, val, "\"}");
return ret == 0 ? used : end + ret;
}
--
2.23.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。