get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 134467,
    "url": "http://patches.dpdk.org/api/patches/134467/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20231117163729.243188-5-stephen@networkplumber.org/",
    "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": "<20231117163729.243188-5-stephen@networkplumber.org>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20231117163729.243188-5-stephen@networkplumber.org",
    "date": "2023-11-17T16:35:58",
    "name": "[v7,4/5] pcapng: avoid using alloca()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "4a9887fd194b2ed3e806bf014a9a0fdf77c54dac",
    "submitter": {
        "id": 27,
        "url": "http://patches.dpdk.org/api/people/27/?format=api",
        "name": "Stephen Hemminger",
        "email": "stephen@networkplumber.org"
    },
    "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/20231117163729.243188-5-stephen@networkplumber.org/mbox/",
    "series": [
        {
            "id": 30330,
            "url": "http://patches.dpdk.org/api/series/30330/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=30330",
            "date": "2023-11-17T16:35:55",
            "name": "dumpcap and pcapng fixes",
            "version": 7,
            "mbox": "http://patches.dpdk.org/series/30330/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/134467/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/134467/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 668D243355;\n\tFri, 17 Nov 2023 17:38:12 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 9B70F42D78;\n\tFri, 17 Nov 2023 17:37:48 +0100 (CET)",
            "from mail-oi1-f176.google.com (mail-oi1-f176.google.com\n [209.85.167.176])\n by mails.dpdk.org (Postfix) with ESMTP id D4429427E8\n for <dev@dpdk.org>; Fri, 17 Nov 2023 17:37:45 +0100 (CET)",
            "by mail-oi1-f176.google.com with SMTP id\n 5614622812f47-3b2e330033fso1354882b6e.3\n for <dev@dpdk.org>; Fri, 17 Nov 2023 08:37:45 -0800 (PST)",
            "from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141])\n by smtp.gmail.com with ESMTPSA id\n f22-20020a631016000000b005bd3f34b10dsm1595541pgl.24.2023.11.17.08.37.43\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Fri, 17 Nov 2023 08:37:44 -0800 (PST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1700239065;\n x=1700843865; darn=dpdk.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=CgabqZvyBZM7J+fRAWDp8OWCDPA2H+xWnMviLGA3Mzw=;\n b=fRhHHG7afbdKjJbAYfoO25wCjCf0ysOPWIDynkiKc7ximl/3efjjqBdWdQwkZyvgmL\n /SgcEY+4oH1YRfdQsmQD0xvPsopcjeGhklMln8X11/EFZiPi+H9VTR2lHbFvBpyLo5rm\n HstDCcs2+oTMkJ+TJIll7EyZ8SMt6S+kM0N94CaxxDz0mVjL05L6p/9i8/mgtS23Jcct\n ZXUAmJxnMVy7FbqNrUAKRv7rYc1F7xocpjaPxLa3da0M/nk46AKBz/GripLBgmftBzgc\n qUkIcy/Nb7bMMLVmloQ5XQo0Q0EuvRO5v44/gf3QBElM2ndY0Uq1YkoHljaW/yZpfOgV\n tUhg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1700239065; x=1700843865;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=CgabqZvyBZM7J+fRAWDp8OWCDPA2H+xWnMviLGA3Mzw=;\n b=oCo7/9D8jw/K8K1IFttB10u9X2kXEcNCgDNKCXednVS816YX5Estygxp5DVTw7n5TL\n iH0sybXCnsI41qISWpH1dTZ1IY6LYgMpV6bSs2vopQYxhoR53ZToSHXO++vsOpwtTEs1\n 1fI+Ds+VLRSpxpcYePKfBlONHwf9HJ7bL0XRJs6qq23bzAHfA0rGhSdDfzW02mowoMYz\n EV+OnTMn3UwEpYme6EqsXf2CeayOU9ot0bsn5SXA5RcyC8Z23yVS7zpXYyWl5X8bFGZH\n 5LLcqGS5NzKhwovcoMTR1FtSg7nub3h5nfg+/+QLKyfcn2VuT+8tvFvJ9Yubf9LJvNgu\n aHxg==",
        "X-Gm-Message-State": "AOJu0YzHZcYUumJR/nt6QmKg6XY2MJuROdBfV+VxCILiPt/cPBi4NxDs\n gJRxN6CQfHxgKbmgLzVTSEBeIgBr5bJ5d9QUciBO0g==",
        "X-Google-Smtp-Source": "\n AGHT+IGsEt+ABZqJKO8D7wmMlkqpDe0wQhA3sELZ1D4MXedWxIoJTBI+iGxeZ3rPzvz2oIXvjRmGjw==",
        "X-Received": "by 2002:a05:6808:4395:b0:3a7:1d15:28fe with SMTP id\n dz21-20020a056808439500b003a71d1528femr18890021oib.56.1700239065045;\n Fri, 17 Nov 2023 08:37:45 -0800 (PST)",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "To": "dev@dpdk.org",
        "Cc": "Stephen Hemminger <stephen@networkplumber.org>, =?utf-8?q?Morten_Br?=\n\t=?utf-8?q?=C3=B8rup?= <mb@smartsharesystems.com>,\n Reshma Pattan <reshma.pattan@intel.com>",
        "Subject": "[PATCH v7 4/5] pcapng: avoid using alloca()",
        "Date": "Fri, 17 Nov 2023 08:35:58 -0800",
        "Message-ID": "<20231117163729.243188-5-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.42.0",
        "In-Reply-To": "<20231117163729.243188-1-stephen@networkplumber.org>",
        "References": "<20230921042349.104150-1-stephen@networkplumber.org>\n <20231117163729.243188-1-stephen@networkplumber.org>",
        "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": "The function alloca() like VLA's has problems if the caller\npasses a large value. Instead use a fixed size buffer (2K)\nwhich will be more than sufficient for the info related blocks\nin the file. Add bounds checks as well.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\nAcked-by: Morten Brørup <mb@smartsharesystems.com>\n---\n lib/pcapng/rte_pcapng.c | 37 ++++++++++++++++---------------------\n 1 file changed, 16 insertions(+), 21 deletions(-)",
    "diff": "diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c\nindex 13fd2b97fb80..f74ec939a9f8 100644\n--- a/lib/pcapng/rte_pcapng.c\n+++ b/lib/pcapng/rte_pcapng.c\n@@ -33,6 +33,9 @@\n /* conversion from DPDK speed to PCAPNG */\n #define PCAPNG_MBPS_SPEED 1000000ull\n \n+/* upper bound for section, stats and interface blocks */\n+#define PCAPNG_BLKSIZ\t2048\n+\n /* Format of the capture file handle */\n struct rte_pcapng {\n \tint  outfd;\t\t/* output file */\n@@ -140,9 +143,8 @@ pcapng_section_block(rte_pcapng_t *self,\n {\n \tstruct pcapng_section_header *hdr;\n \tstruct pcapng_option *opt;\n-\tvoid *buf;\n+\tuint8_t buf[PCAPNG_BLKSIZ];\n \tuint32_t len;\n-\tssize_t cc;\n \n \tlen = sizeof(*hdr);\n \tif (hw)\n@@ -158,8 +160,7 @@ pcapng_section_block(rte_pcapng_t *self,\n \tlen += pcapng_optlen(0);\n \tlen += sizeof(uint32_t);\n \n-\tbuf = calloc(1, len);\n-\tif (!buf)\n+\tif (len > sizeof(buf))\n \t\treturn -1;\n \n \thdr = (struct pcapng_section_header *)buf;\n@@ -193,10 +194,7 @@ pcapng_section_block(rte_pcapng_t *self,\n \t/* clone block_length after option */\n \tmemcpy(opt, &hdr->block_length, sizeof(uint32_t));\n \n-\tcc = write(self->outfd, buf, len);\n-\tfree(buf);\n-\n-\treturn cc;\n+\treturn write(self->outfd, buf, len);\n }\n \n /* Write an interface block for a DPDK port */\n@@ -213,7 +211,7 @@ rte_pcapng_add_interface(rte_pcapng_t *self, uint16_t port,\n \tstruct pcapng_option *opt;\n \tconst uint8_t tsresol = 9;\t/* nanosecond resolution */\n \tuint32_t len;\n-\tvoid *buf;\n+\tuint8_t buf[PCAPNG_BLKSIZ];\n \tchar ifname_buf[IF_NAMESIZE];\n \tchar ifhw[256];\n \tuint64_t speed = 0;\n@@ -267,8 +265,7 @@ rte_pcapng_add_interface(rte_pcapng_t *self, uint16_t port,\n \tlen += pcapng_optlen(0);\n \tlen += sizeof(uint32_t);\n \n-\tbuf = alloca(len);\n-\tif (!buf)\n+\tif (len > sizeof(buf))\n \t\treturn -1;\n \n \thdr = (struct pcapng_interface_block *)buf;\n@@ -296,17 +293,16 @@ rte_pcapng_add_interface(rte_pcapng_t *self, uint16_t port,\n \t\topt = pcapng_add_option(opt, PCAPNG_IFB_HARDWARE,\n \t\t\t\t\t ifhw, strlen(ifhw));\n \tif (filter) {\n-\t\t/* Encoding is that the first octet indicates string vs BPF */\n \t\tsize_t len;\n-\t\tchar *buf;\n \n \t\tlen = strlen(filter) + 1;\n-\t\tbuf = alloca(len);\n-\t\t*buf = '\\0';\n-\t\tmemcpy(buf + 1, filter, len);\n+\t\topt->code = PCAPNG_IFB_FILTER;\n+\t\topt->length = len;\n+\t\t/* Encoding is that the first octet indicates string vs BPF */\n+\t\topt->data[0] = 0;\n+\t\tmemcpy(opt->data + 1, filter, strlen(filter));\n \n-\t\topt = pcapng_add_option(opt, PCAPNG_IFB_FILTER,\n-\t\t\t\t\tbuf, len);\n+\t\topt = (struct pcapng_option *)((uint8_t *)opt + pcapng_optlen(len));\n \t}\n \n \topt = pcapng_add_option(opt, PCAPNG_OPT_END, NULL, 0);\n@@ -333,7 +329,7 @@ rte_pcapng_write_stats(rte_pcapng_t *self, uint16_t port_id,\n \tuint64_t start_time = self->offset_ns;\n \tuint64_t sample_time;\n \tuint32_t optlen, len;\n-\tuint8_t *buf;\n+\tuint8_t buf[PCAPNG_BLKSIZ];\n \n \tRTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);\n \n@@ -353,8 +349,7 @@ rte_pcapng_write_stats(rte_pcapng_t *self, uint16_t port_id,\n \t\toptlen += pcapng_optlen(0);\n \n \tlen = sizeof(*hdr) + optlen + sizeof(uint32_t);\n-\tbuf = alloca(len);\n-\tif (buf == NULL)\n+\tif (len > sizeof(buf))\n \t\treturn -1;\n \n \thdr = (struct pcapng_statistics *)buf;\n",
    "prefixes": [
        "v7",
        "4/5"
    ]
}