get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/125814/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 125814,
    "url": "http://patches.dpdk.org/api/patches/125814/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230405154414.183915-3-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": "<20230405154414.183915-3-bruce.richardson@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230405154414.183915-3-bruce.richardson@intel.com",
    "date": "2023-04-05T15:44:11",
    "name": "[v2,2/5] telemetry: remove variable length array in printf fn",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "615cecdca39d481f1c936156c16327e9723bd28c",
    "submitter": {
        "id": 20,
        "url": "http://patches.dpdk.org/api/people/20/?format=api",
        "name": "Bruce Richardson",
        "email": "bruce.richardson@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20230405154414.183915-3-bruce.richardson@intel.com/mbox/",
    "series": [
        {
            "id": 27628,
            "url": "http://patches.dpdk.org/api/series/27628/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=27628",
            "date": "2023-04-05T15:44:09",
            "name": "telemetry: remove variable length arrays",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/27628/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/125814/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/125814/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 9D6DC428D4;\n\tWed,  5 Apr 2023 17:44:46 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id BD21842C54;\n\tWed,  5 Apr 2023 17:44:36 +0200 (CEST)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n by mails.dpdk.org (Postfix) with ESMTP id 46C0241156\n for <dev@dpdk.org>; Wed,  5 Apr 2023 17:44:34 +0200 (CEST)",
            "from orsmga002.jf.intel.com ([10.7.209.21])\n by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 05 Apr 2023 08:44:32 -0700",
            "from silpixa00401385.ir.intel.com ([10.237.214.40])\n by orsmga002.jf.intel.com with ESMTP; 05 Apr 2023 08:44:31 -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=1680709474; x=1712245474;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=ogeTmaVhDWFYJkgcf4GTeduVwTLiQZUnh6LH7/evuyQ=;\n b=RECaucDdm9q1TXgCNlcZVFAmntq5MrsvnYWObqGWjFFkI9r7DHu9kCRW\n pB0msBzPQBVFtZqbhDrFKQ5gibThpB/40ww216/g2d6wJMfFz/T6+VL6H\n Zue4QhLWkNmD1yU87/u4UdH56p5igoTcRLCbc9uEt4ip4oZjB+xfDiEOd\n rE+xX//Mzzdpd+Yl4RPqEIy4FzE20aTYFWRXJsqpYbIFRnN3CB+Hl7J6I\n SAAy53c08r0VriKJhKWob2/CSLAiKiuITbKhpQXzUm77k3jTuexLa6GTc\n sQKT4NSApkqIsGaQwGOr1KyMXbxlE7vapVjDFbKtFckPv4v0JODAGKbTR Q==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6600,9927,10671\"; a=\"339980369\"",
            "E=Sophos;i=\"5.98,321,1673942400\"; d=\"scan'208\";a=\"339980369\"",
            "E=McAfee;i=\"6600,9927,10671\"; a=\"686790275\"",
            "E=Sophos;i=\"5.98,321,1673942400\"; d=\"scan'208\";a=\"686790275\""
        ],
        "X-ExtLoop1": "1",
        "From": "Bruce Richardson <bruce.richardson@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "ciara.power@intel.com, roretzla@linux.microsoft.com,\n Bruce Richardson <bruce.richardson@intel.com>",
        "Subject": "[PATCH v2 2/5] telemetry: remove variable length array in printf fn",
        "Date": "Wed,  5 Apr 2023 16:44:11 +0100",
        "Message-Id": "<20230405154414.183915-3-bruce.richardson@intel.com>",
        "X-Mailer": "git-send-email 2.37.2",
        "In-Reply-To": "<20230405154414.183915-1-bruce.richardson@intel.com>",
        "References": "<20230310181836.162336-1-bruce.richardson@intel.com>\n <20230405154414.183915-1-bruce.richardson@intel.com>",
        "MIME-Version": "1.0",
        "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": "The json_snprintf function, used to add json characters on to a buffer,\nleaving the buffer unmodified in case of error, used a variable length\narray to store the data temporarily while checking for overflow. VLAs\ncan be unsafe, and are unsupported by some compilers, so remove use of\nthe VLA.\n\nFor the normal case where there is only a small amount of existing text\nin the buffer (<4 chars) to be preserved, save that off temporarily to a\nlocal array, and restore on error. To handle cases where there is more\nthan a few characters in the buffer, we use the existing logic of doing\nthe print to a temporary buffer initially and then copying. In this\ncase, though we use malloc-allocated buffer rather than VLA.\n\nWithin the unit tests, the \"telemetry_data_autotests\" test cases - which\nmimic real telemetry use - all exercise the first path. The\ntelemetry_json_autotest cases work directly with generating json, and\nuse uninitialized buffers so also test the second, malloc-allocated\nbuffer, cases.\n\nSigned-off-by: Bruce Richardson <bruce.richardson@intel.com>\n---\n lib/telemetry/telemetry_json.h | 32 ++++++++++++++++++++++++++++----\n 1 file changed, 28 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h\nindex 744bbfe053..cb18453449 100644\n--- a/lib/telemetry/telemetry_json.h\n+++ b/lib/telemetry/telemetry_json.h\n@@ -8,6 +8,7 @@\n #include <inttypes.h>\n #include <stdarg.h>\n #include <stdio.h>\n+#include <stdlib.h>\n #include <rte_common.h>\n #include <rte_telemetry.h>\n \n@@ -30,17 +31,40 @@ __rte_format_printf(3, 4)\n static inline int\n __json_snprintf(char *buf, const int len, const char *format, ...)\n {\n-\tchar tmp[len];\n \tva_list ap;\n+\tchar tmp[4];\n+\tchar *newbuf;\n \tint ret;\n \n+\tif (len == 0)\n+\t\treturn 0;\n+\n+\t/* to ensure unmodified if we overflow, we save off any values currently in buf\n+\t * before we printf, if they are short enough. We restore them on error.\n+\t */\n+\tif (strnlen(buf, sizeof(tmp)) < sizeof(tmp)) {\n+\t\tstrcpy(tmp, buf);  /* strcpy is safe as we know the length */\n+\t\tva_start(ap, format);\n+\t\tret = vsnprintf(buf, len, format, ap);\n+\t\tva_end(ap);\n+\t\tif (ret > 0 && ret < len)\n+\t\t\treturn ret;\n+\t\tstrcpy(buf, tmp);  /* restore on error */\n+\t\treturn 0;\n+\t}\n+\n+\t/* in normal operations should never hit this, but can do if buffer is\n+\t * incorrectly initialized e.g. in unit test cases\n+\t */\n \tva_start(ap, format);\n-\tret = vsnprintf(tmp, sizeof(tmp), format, ap);\n+\tret = vasprintf(&newbuf, format, ap);\n \tva_end(ap);\n-\tif (ret > 0 && ret < (int)sizeof(tmp) && ret < len) {\n-\t\tstrcpy(buf, tmp);\n+\tif (ret > 0 && ret < len) {\n+\t\tstrcpy(buf, newbuf);\n+\t\tfree(newbuf);\n \t\treturn ret;\n \t}\n+\tfree(newbuf);\n \treturn 0; /* nothing written or modified */\n }\n \n",
    "prefixes": [
        "v2",
        "2/5"
    ]
}