Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2041445/?format=api
{ "id": 2041445, "url": "http://patchwork.ozlabs.org/api/patches/2041445/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20250203091203.47590-2-heinrich.schuchardt@canonical.com/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api", "name": "U-Boot", "link_name": "uboot", "list_id": "u-boot.lists.denx.de", "list_email": "u-boot@lists.denx.de", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20250203091203.47590-2-heinrich.schuchardt@canonical.com>", "list_archive_url": null, "date": "2025-02-03T09:11:59", "name": "[v3,1/4] net: lwip: tftp: fix find_option()", "commit_ref": "10917df17f247d3b0a7f5ca992b97bd2728ef09e", "pull_url": null, "state": "accepted", "archived": false, "hash": "bca041d57bab02424ffd3298bdbae471048b4293", "submitter": { "id": 82181, "url": "http://patchwork.ozlabs.org/api/people/82181/?format=api", "name": "Heinrich Schuchardt", "email": "heinrich.schuchardt@canonical.com" }, "delegate": { "id": 157425, "url": "http://patchwork.ozlabs.org/api/users/157425/?format=api", "username": "jforissier", "first_name": "Jerome", "last_name": "Forissier", "email": "jerome.forissier@linaro.org" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20250203091203.47590-2-heinrich.schuchardt@canonical.com/mbox/", "series": [ { "id": 442578, "url": "http://patchwork.ozlabs.org/api/series/442578/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=442578", "date": "2025-02-03T09:11:58", "name": "net: use strnstr() for lwip_strnstr()", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/442578/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2041445/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2041445/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<u-boot-bounces@lists.denx.de>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=canonical.com header.i=@canonical.com\n header.a=rsa-sha256 header.s=20210705 header.b=rnIIXsDJ;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=85.214.62.61; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)", "phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=canonical.com", "phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de", "phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=canonical.com header.i=@canonical.com\n header.b=\"rnIIXsDJ\";\n\tdkim-atps=neutral", "phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=canonical.com", "phobos.denx.de; spf=pass\n smtp.mailfrom=heinrich.schuchardt@canonical.com" ], "Received": [ "from phobos.denx.de (phobos.denx.de [85.214.62.61])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4YmgkF1KBBz20J0\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 3 Feb 2025 20:12:21 +1100 (AEDT)", "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 5039880763;\n\tMon, 3 Feb 2025 10:12:13 +0100 (CET)", "by phobos.denx.de (Postfix, from userid 109)\n id AE956801DE; Mon, 3 Feb 2025 10:12:11 +0100 (CET)", "from smtp-relay-canonical-1.canonical.com\n (smtp-relay-canonical-1.canonical.com [185.125.188.121])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 8B7BC80608\n for <u-boot@lists.denx.de>; Mon, 3 Feb 2025 10:12:09 +0100 (CET)", "from LT2ubnt.. (dynamic-046-114-108-254.46.114.pool.telefonica.de\n [46.114.108.254])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 44A2741EB6;\n Mon, 3 Feb 2025 09:12:08 +0000 (UTC)" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,\n DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,\n RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED,\n RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham\n autolearn_force=no version=3.4.2", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com;\n s=20210705; t=1738573928;\n bh=v7kUquQoYPodvHQnrrsaD6rLhSzswdTq2ZVkmHQhjls=;\n h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n MIME-Version;\n b=rnIIXsDJ7tAnWVL8ad8MBiCpG5DqzoNT5I65N8z6n+fuFxGsvTterEXbchpuB/jwg\n cdhJs7JqGWk9cWx7UwLuNQ0kUT5yQC8EL3CYV4WbLKyvpF0tBQ2ZeqiQCca4eJv1QP\n cFA6sY4hOX6nRMHVBcmpdOzA6+hfHquSOCTF2h26k+OJNZ4NbnEZJfRfOKUGmJKmgZ\n UZRRowOzj43zoDgSiBL/s/gShW34SYUvBtsuRfUS9CgGg4YifAy78GV5SBMa7Wl2vV\n y2rHkX6i1JJS/5+aBF7RUEXS7hiQd2rURwh6CgQHeqJPjITW8Wlw6bjTJG6d54myCd\n ehzawCOGjxvfw==", "From": "Heinrich Schuchardt <heinrich.schuchardt@canonical.com>", "To": "Jerome Forissier <jerome.forissier@linaro.org>", "Cc": "Tom Rini <trini@konsulko.com>,\n Marek Vasut <marek.vasut+renesas@mailbox.org>,\n Ilias Apalodimas <ilias.apalodimas@linaro.org>,\n Simon Glass <sjg@chromium.org>, u-boot@lists.denx.de,\n Heinrich Schuchardt <heinrich.schuchardt@canonical.com>", "Subject": "[PATCH v3 1/4] net: lwip: tftp: fix find_option()", "Date": "Mon, 3 Feb 2025 10:11:59 +0100", "Message-ID": "<20250203091203.47590-2-heinrich.schuchardt@canonical.com>", "X-Mailer": "git-send-email 2.47.1", "In-Reply-To": "<20250203091203.47590-1-heinrich.schuchardt@canonical.com>", "References": "<20250203091203.47590-1-heinrich.schuchardt@canonical.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "u-boot@lists.denx.de", "X-Mailman-Version": "2.1.39", "Precedence": "list", "List-Id": "U-Boot discussion <u-boot.lists.denx.de>", "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>", "List-Archive": "<https://lists.denx.de/pipermail/u-boot/>", "List-Post": "<mailto:u-boot@lists.denx.de>", "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>", "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>", "Errors-To": "u-boot-bounces@lists.denx.de", "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>", "X-Virus-Scanned": "clamav-milter 0.103.8 at phobos.denx.de", "X-Virus-Status": "Clean" }, "content": "Find_option() is used to retrieve the block size value in an option\nacknowledgment in response to a request containing a block size option\naccording to RFC2348.\n\nThe format of an OACK response is described in RFC2347 as\n\n+-------+---~~---+---+---~~---+---+---~~---+---+---~~---+---+\n| opc | opt1 | 0 | value1 | 0 | optN | 0 | valueN | 0 |\n+-------+---~~---+---+---~~---+---+---~~---+---+---~~---+---+\n\nThe current implementation of find_option() only works if\n\n* blksize is the first option\n* lwip_strnstr() ignores the length parameter,\n i.e. is implemented via strstr()\n\nThe OACK messages starts with 0x00 0x06. If 'blksize' is the first option,\nstrstr() reports a match when the first parameter points to 0x06. Adding\nthe string length of 'blksize' plus 2 to the location of the 0x06 byte\npoints to the value.\n\nFind_option() would report a match for option 'blksize' if the response\ncontained an option called 'foo_blksize_bar'. In this case find_option()\nwould return 'bar' as the value string.\n\nIf 'blksize' were the second option, find_option() would return a pointer\nto the second character of the value string.\n\nFurthermore find_option() does not detect if the value string is NUL\nterminated. This may lead to a buffer overrun.\n\nProvide an implementation that correctly steps from option to option.\n\nFixes: 27d7ccda94fa (\"net: lwip: tftp: add support of blksize option to client\")\nSigned-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>\nReviewed-by: Jerome Forissier <jerome.forissier@linaro.org>\nTested-by: Jerome Forissier <jerome.forissier@linaro.org> (qemu_arm64_lwip)\n---\nv3:\n\trename variable match to diff\nv2:\n\tnew patch\n---\n lib/lwip/lwip/src/apps/tftp/tftp.c | 54 +++++++++++++++++++++++++-----\n 1 file changed, 45 insertions(+), 9 deletions(-)", "diff": "diff --git a/lib/lwip/lwip/src/apps/tftp/tftp.c b/lib/lwip/lwip/src/apps/tftp/tftp.c\nindex 56aeabc4d73..e85e3623066 100644\n--- a/lib/lwip/lwip/src/apps/tftp/tftp.c\n+++ b/lib/lwip/lwip/src/apps/tftp/tftp.c\n@@ -264,19 +264,55 @@ static u16_t payload_size(void)\n return TFTP_DEFAULT_BLOCK_SIZE;\n }\n \n+/**\n+ * find_option() - check if OACK message contains option\n+ *\n+ * @p:\t\tmessage buffer\n+ * @option:\toption key\n+ * Return:\toption value\n+ */\n static const char *\n find_option(struct pbuf *p, const char *option)\n {\n- int i;\n- u16_t optlen = strlen(option);\n- const char *b = p->payload;\n-\n- for (i = 0; i + optlen + 1 < p->len; i++) {\n- if (lwip_strnstr(b + i, option, optlen))\n- return b + i + optlen + 2;\n- }\n+\tconst char *pos = p->payload;\n+\tint rem = p->len;\n+\n+\t/*\n+\t * According to RFC 2347 the OACK packet has the following format:\n+\t *\n+\t * +-------+---~~---+---+---~~---+---+---~~---+---+---~~---+---+\n+\t * | opc | opt1 | 0 | value1 | 0 | optN | 0 | valueN | 0 |\n+\t * +-------+---~~---+---+---~~---+---+---~~---+---+---~~---+---+\n+\t */\n+\n+\t/* Skip opc */\n+\tpos += 2;\n+\trem -= 2;\n+\tif (rem <= 0)\n+\t\treturn NULL;\n+\n+\tfor (;;) {\n+\t\tint len;\n+\t\tint diff;\n+\n+\t\tlen = strnlen(pos, rem) + 1;\n+\t\tif (rem < len)\n+\t\t\tbreak;\n+\t\tdiff = strcmp(pos, option);\n+\t\t/* Skip option */\n+\t\tpos += len;\n+\t\trem -= len;\n+\t\tlen = strnlen(pos, rem) + 1;\n+\t\tif (rem < len)\n+\t\t\tbreak;\n+\t\tif (!diff)\n+\t\t\treturn pos;\n+\t\t/* Skip value */\n+\t\tpos += len;\n+\t\trem -= len;\n+\t}\n \n- return NULL;\n+\treturn NULL;\n }\n \n static void\n", "prefixes": [ "v3", "1/4" ] }