Show a patch.

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

{
    "id": 3956,
    "url": "https://patchwork.libcamera.org/api/patches/3956/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3956/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20200605150858.116564-3-email@uajain.com>",
    "date": "2020-06-05T15:09:16",
    "name": "[libcamera-devel,v2,2/2] libcamera: ipa_module: Fix implicit sign-extension in elfSection",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "f72735bdbfac6fefa1d49a22aaa0d8b083fe6b2c",
    "submitter": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/people/1/?format=api",
        "name": "Umang Jain",
        "email": "email@uajain.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/3956/mbox/",
    "series": [
        {
            "id": 960,
            "url": "https://patchwork.libcamera.org/api/series/960/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=960",
            "date": "2020-06-05T15:09:14",
            "name": "Fix implicit sign-extension",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/960/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3956/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3956/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<bounces+15657259-5c31-libcamera-devel=lists.libcamera.org@em7280.uajain.com>",
        "Received": [
            "from o1.f.az.sendgrid.net (o1.f.az.sendgrid.net [208.117.55.132])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7ED9661375\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  5 Jun 2020 17:09:17 +0200 (CEST)",
            "by filterdrecv-p3mdw1-6f5df8956d-k4m5j with SMTP id\n\tfilterdrecv-p3mdw1-6f5df8956d-k4m5j-20-5EDA601B-10B\n\t2020-06-05 15:09:16.217296695 +0000 UTC m=+154528.959643534",
            "from mail.uajain.com (unknown)\n\tby ismtpd0002p1maa1.sendgrid.net (SG) with ESMTP\n\tid TrrIha16RLWz6BbsMNMt1A Fri, 05 Jun 2020 15:09:15.860 +0000 (UTC)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=uajain.com\n\theader.i=@uajain.com header.b=\"m8TXVf4c\"; \n\tdkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=uajain.com;\n\th=from:subject:in-reply-to:references:mime-version:to:cc:\n\tcontent-transfer-encoding:content-type;\n\ts=s1; bh=zb7xK6hgU4i0ysUPm9WZ7FU7whfeEvDMKcN/hMCRlY4=;\n\tb=m8TXVf4czO9SK0nCNvC99Ik9v1/xKxJi4GH/YbFhK54m5Lehpni2ivaodIFUq7MZDyJh\n\tVrQ2LwriWTVQaha5JY1QNYbD0w/fGtXsPgYRIlxQ3VMvXAsCMy+zOL+0XzI5DReBcrwLDb\n\trZfK53KhcPBcLOMp8xRIHwuNwtfcK3CPY=",
        "From": "Umang Jain <email@uajain.com>",
        "Date": "Fri, 05 Jun 2020 15:09:16 +0000 (UTC)",
        "Message-Id": "<20200605150858.116564-3-email@uajain.com>",
        "In-Reply-To": "<20200605150858.116564-1-email@uajain.com>",
        "References": "<20200605150858.116564-1-email@uajain.com>",
        "Mime-Version": "1.0",
        "X-SG-EID": "1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPcYFho/XlHW4zrk5y9XrA/WkWG4sk/UCmhRlzualOiULxl5LXIQ4wsfqBXK+6696ZggFFnGBRpupFcbIySjmG0Q7Sdh6Az2uuaRnpCeKLLclwtiQk5BKyBpHBKcYn3JWyg4WrO+oeqHwZSKMGsBTEwXq4qzr3dWB2tBnvqkkn5o4g9uP3p8JInX2T1HTOSDNs5MWpo/Y5UCMtA6igzAwOomw==",
        "To": "laurent.pinchart@ideasonboard.com, libcamera-devel@lists.libcamera.org",
        "Content-Transfer-Encoding": "7bit",
        "Content-Type": "text/plain; charset=us-ascii",
        "Subject": "[libcamera-devel] [PATCH v2 2/2] libcamera: ipa_module: Fix\n\timplicit sign-extension in elfSection",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "<libcamera-devel.lists.libcamera.org>",
        "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>",
        "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>",
        "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>",
        "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>",
        "X-List-Received-Date": "Fri, 05 Jun 2020 15:09:17 -0000"
    },
    "content": "Given how the elfSection() is used, the sub-expression\n       (idx * eHdr->e_shentsize)\nhas effectively two (16 bits, unsigned) operands.\nThe sub-expression is promoted to type int (32 bits, signed) for\nmultiplication and then added to eHdr->e_shoff, which is uint32_t\non 32-bit platforms and uint64_t on 64-bit platforms. Since eHdr->e_shoff\nis unsigned, the integer conversion rules dictates that the other signed\noperand(i.e. the resultant of aforementioned sub-expression) will be\nconverted to unsigned type too. This causes sign-extension for both of\nthe above operands to match eHdr->e_shoff's type and should be avoided.\n\nThe solution is to explicitly cast one of the operands of the\nsub-expression with unsigned int type. Hence, the other operand will be\ninteger promoted and the resultant will also be of unsigned int type,\nnot requiring to bother about a sign-extension.\n\nReported-by: Coverity CID=280008\nReported-by: Coverity CID=280009\nReported-by: Coverity CID=280010\nSigned-off-by: Umang Jain <email@uajain.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/ipa_module.cpp | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp\nindex f54dd8b..d79151d 100644\n--- a/src/libcamera/ipa_module.cpp\n+++ b/src/libcamera/ipa_module.cpp\n@@ -93,7 +93,8 @@ ElfW(Shdr) *elfSection(Span<uint8_t> elf, ElfW(Ehdr) *eHdr, unsigned int idx)\n \tif (idx >= eHdr->e_shnum)\n \t\treturn nullptr;\n \n-\toff_t offset = eHdr->e_shoff + idx * eHdr->e_shentsize;\n+\toff_t offset = eHdr->e_shoff + idx *\n+\t\t\t\t       static_cast<uint32_t>(eHdr->e_shentsize);\n \treturn elfPointer<ElfW(Shdr)>(elf, offset);\n }\n \n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "2/2"
    ]
}