Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/116130/?format=api
http://patches.dpdk.org/api/patches/116130/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20220909093523.471727-6-bruce.richardson@intel.com/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20220909093523.471727-6-bruce.richardson@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20220909093523.471727-6-bruce.richardson@intel.com", "date": "2022-09-09T09:35:15", "name": "[v3,05/13] telemetry: add escaping of strings in arrays", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "31332263580a8d97d3e7ff264bd38a53f8f47f5d", "submitter": { "id": 20, "url": "http://patches.dpdk.org/api/people/20/?format=api", "name": "Bruce Richardson", "email": "bruce.richardson@intel.com" }, "delegate": { "id": 24651, "url": "http://patches.dpdk.org/api/users/24651/?format=api", "username": "dmarchand", "first_name": "David", "last_name": "Marchand", "email": "david.marchand@redhat.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20220909093523.471727-6-bruce.richardson@intel.com/mbox/", "series": [ { "id": 24617, "url": "http://patches.dpdk.org/api/series/24617/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=24617", "date": "2022-09-09T09:35:13", "name": "telemetry JSON escaping and other enhancements", "version": 3, "mbox": "http://patches.dpdk.org/series/24617/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/116130/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/116130/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 1065FA0540;\n\tFri, 9 Sep 2022 11:36:05 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id AEB1E42905;\n\tFri, 9 Sep 2022 11:35:50 +0200 (CEST)", "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n by mails.dpdk.org (Postfix) with ESMTP id 4F0B141155\n for <dev@dpdk.org>; Fri, 9 Sep 2022 11:35:47 +0200 (CEST)", "from orsmga004.jf.intel.com ([10.7.209.38])\n by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 09 Sep 2022 02:35:46 -0700", "from silpixa00401385.ir.intel.com ([10.237.214.161])\n by orsmga004.jf.intel.com with ESMTP; 09 Sep 2022 02:35:44 -0700" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1662716147; x=1694252147;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=Wc4msroVjF7qakmFzGILlAml5a7kYcygtN+xKqYE3pE=;\n b=ibKfyboAkmbzR/JMv8UKQgQxAlG40NzAJdRKKUagrKhiYiBK3ejYt6N7\n QhvYEASX7+tBBreTKtCP0qt0UzEEiUax3QYYLuPmL/yuc7Pc5a7nMYxfr\n 9dBYUeKUdyQonEI/fPLU/55XxL0k9bqmVafA6izd6LVCmpZXMUvgikRaX\n fmFXXol2SWeNN/Z7hiRiYwo41DF8haJQCm9vtpLfwyWk4qccEZuLCyx7B\n XiuE30uadrQwDtOPXbG1WEGwKCY12AodAd1/RHb1ZnHkP1i9l1Bv4nD/o\n famCKa6tMHVLR+c4OuwW1t+sBaa06CYgA0lhiJ0SpRVpVUwUYE5lTeQ73 A==;", "X-IronPort-AV": [ "E=McAfee;i=\"6500,9779,10464\"; a=\"297437126\"", "E=Sophos;i=\"5.93,302,1654585200\"; d=\"scan'208\";a=\"297437126\"", "E=Sophos;i=\"5.93,302,1654585200\"; d=\"scan'208\";a=\"740996375\"" ], "X-ExtLoop1": "1", "From": "Bruce Richardson <bruce.richardson@intel.com>", "To": "dev@dpdk.org", "Cc": "Bruce Richardson <bruce.richardson@intel.com>,\n Ciara Power <ciara.power@intel.com>,\n =?utf-8?q?Morten_Br=C3=B8rup?= <mb@smartsharesystems.com>", "Subject": "[PATCH v3 05/13] telemetry: add escaping of strings in arrays", "Date": "Fri, 9 Sep 2022 10:35:15 +0100", "Message-Id": "<20220909093523.471727-6-bruce.richardson@intel.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20220909093523.471727-1-bruce.richardson@intel.com>", "References": "<20220623164245.561371-1-bruce.richardson@intel.com>\n <20220909093523.471727-1-bruce.richardson@intel.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "When strings are added to an array variable, we need to properly escape\nthe invalid json characters in the strings.\n\nSigned-off-by: Bruce Richardson <bruce.richardson@intel.com>\nAcked-by: Ciara Power <ciara.power@intel.com>\nAcked-by: Morten Brørup <mb@smartsharesystems.com>\n---\n lib/telemetry/telemetry_json.h | 28 +++++++++++++++++++---------\n 1 file changed, 19 insertions(+), 9 deletions(-)", "diff": "diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h\nindex 13df5d07e3..c4442a0bf0 100644\n--- a/lib/telemetry/telemetry_json.h\n+++ b/lib/telemetry/telemetry_json.h\n@@ -52,17 +52,22 @@ static const char control_chars[0x20] = {\n \n /**\n * @internal\n- * Does the same as __json_snprintf(buf, len, \"\\\"%s\\\"\", str)\n- * except that it does proper escaping as necessary.\n+ * This function acts the same as __json_snprintf(buf, len, \"%s%s%s\", prefix, str, suffix)\n+ * except that it does proper escaping of \"str\" as necessary. Prefix and suffix should be compile-\n+ * time constants not needing escaping.\n * Drops any invalid characters we don't support\n */\n static inline int\n-__json_format_str(char *buf, const int len, const char *str)\n+__json_format_str(char *buf, const int len, const char *prefix, const char *str, const char *suffix)\n {\n \tchar tmp[len];\n \tint tmpidx = 0;\n \n-\ttmp[tmpidx++] = '\"';\n+\twhile (*prefix != '\\0' && tmpidx < len)\n+\t\ttmp[tmpidx++] = *prefix++;\n+\tif (tmpidx >= len)\n+\t\treturn 0;\n+\n \twhile (*str != '\\0') {\n \t\tif (*str < (int)RTE_DIM(control_chars)) {\n \t\t\tint idx = *str; /* compilers don't like char type as index */\n@@ -75,7 +80,7 @@ __json_format_str(char *buf, const int len, const char *str)\n \t\t\ttmp[tmpidx++] = *str;\n \t\t} else\n \t\t\ttmp[tmpidx++] = *str;\n-\t\t/* we always need space for closing quote and null character.\n+\t\t/* we always need space for (at minimum) closing quote and null character.\n \t\t * Ensuring at least two free characters also means we can always take an\n \t\t * escaped character like \"\\n\" without overflowing\n \t\t */\n@@ -83,7 +88,12 @@ __json_format_str(char *buf, const int len, const char *str)\n \t\t\treturn 0;\n \t\tstr++;\n \t}\n-\ttmp[tmpidx++] = '\"';\n+\n+\twhile (*suffix != '\\0' && tmpidx < len)\n+\t\ttmp[tmpidx++] = *suffix++;\n+\tif (tmpidx >= len)\n+\t\treturn 0;\n+\n \ttmp[tmpidx] = '\\0';\n \n \tstrcpy(buf, tmp);\n@@ -108,7 +118,7 @@ rte_tel_json_empty_obj(char *buf, const int len, const int used)\n static inline int\n rte_tel_json_str(char *buf, const int len, const int used, const char *str)\n {\n-\treturn used + __json_format_str(buf + used, len - used, str);\n+\treturn used + __json_format_str(buf + used, len - used, \"\\\"\", str, \"\\\"\");\n }\n \n /* Appends a string into the JSON array in the provided buffer. */\n@@ -118,9 +128,9 @@ rte_tel_json_add_array_string(char *buf, const int len, const int used,\n {\n \tint ret, end = used - 1; /* strip off final delimiter */\n \tif (used <= 2) /* assume empty, since minimum is '[]' */\n-\t\treturn __json_snprintf(buf, len, \"[\\\"%s\\\"]\", str);\n+\t\treturn __json_format_str(buf, len, \"[\\\"\", str, \"\\\"]\");\n \n-\tret = __json_snprintf(buf + end, len - end, \",\\\"%s\\\"]\", str);\n+\tret = __json_format_str(buf + end, len - end, \",\\\"\", str, \"\\\"]\");\n \treturn ret == 0 ? used : end + ret;\n }\n \n", "prefixes": [ "v3", "05/13" ] }{ "id": 116130, "url": "