From patchwork Wed Oct 31 23:55:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 991757 X-Patchwork-Delegate: hauke@hauke-m.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="e9aaWFvq"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ltcv6Gcs"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42llb35v0gz9s0t for ; Thu, 1 Nov 2018 10:55:43 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=22f4cAYFo8FZIOu5Qx+jV/RFRlqCIojiGAPJ8FQ4Lpw=; b=e9aaWFvqIze6lJ 2oUmV5AI3oAISLfYdx+4vU9WvMwTBLZyQVYxCkLxLdZ2dfgV7r2cVs4F2Wr0nr1RKieHeIXnvcsKA EDkUyiCm32K2Ft3zW0yQv4nnerqPpIyGviJ5Z+xjqKPTmiFux3zLJW0sN18wh7nq5xtAfwbz9n3Mf ISgqpFuwz8iuau0k4nqPzh/RJAJq6xcnSM4jRvEVKxahjnU3bno5hLMV8hOEU2HjtTCL4i0zW9z2o Y5DimZOfhGpgEWOr0oxCMJZeMgT16M8kXxKqI+y3jdWcuvJc4sMBY9GhIGhYWMu1Ni4j2vUwcZsg6 7nvjt9+kLDq+cNsIyDAg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gI0Kh-0005dc-J6; Wed, 31 Oct 2018 23:55:31 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gI0Ke-0005c2-L4 for openwrt-devel@lists.openwrt.org; Wed, 31 Oct 2018 23:55:30 +0000 Received: by mail-pf1-x441.google.com with SMTP id i62-v6so531677pfi.0 for ; Wed, 31 Oct 2018 16:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=VBiqoomCBoIOtjxC0HqJ5ZLicKIVt8on1FnG5yLAcvY=; b=ltcv6Gcs+Y/YFPy6zZbCcG5RrsMWMDkfgKwlSPRDIDDvtNkIEz9STc6Yjempr0ej+d 5iAtmlzW7GqnSxELFW3gYWFPDIkbStXasc517BWIrxKxBtxG2EP/dOPHTd5ap6hUGoNp b2BFNs15718L33iN0x1gjGQ5O9NCvgiU8TSZAQuQ5Jlg+AlpdmKpZq9Xb6Boq165MqAQ /bLX+Fp5ojLK36AmdKLvTnHXinRpra+3DCdDhOc1XU6GpD/KXipJpl469WcnQTSkhwZW LyRU6atC6c+QnBYGFA7IwksL1Y6Jwzbhp6Gxi8Fwvdy3DPtdWSoZkT1T6kYydDDF5FRo i3rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=VBiqoomCBoIOtjxC0HqJ5ZLicKIVt8on1FnG5yLAcvY=; b=qcryqeHMPHWI8z8CaXvezHFSI1Y3hQC9JtnWWZWXk/h50bddrQ+KUtnptY1lvUyNWW 9L9Q3f2N2Hf1/OatM50xBFfMEgp3K7EkXgiDz23tteTdjMSkvSzog+z+b3TisNExWMiq AcE91rVr+pM8kCwJ87FIgi91BuSzr/MdIsiEbxCnRzVIF2Xl5np9f8bxEhYsWZy7U+Jk vjnOu6duBBM3DbioDFK4TfoThMJpkhPnSec9/yRnDA/zGNIsh6IaDBJIlEAUUWWupGCO 8witGd9iygrdCJtAT84i/E27Js9Kk1daTIhhHuE/MC2YtkriAcYmleh3tNCaV2V/d2hq Iz2A== X-Gm-Message-State: AGRZ1gL1KIZeSnyUnauqPXzjHmHsLfQcmwfUOPKb4oCFFN/7D4ykhsrx iDGFXTFQq7f4LAnnN8ZhG2sfYdO+ X-Google-Smtp-Source: AJdET5csjEBYlMFbzqNP4uRMcAkDEcBeEHnZ2n27wF+1/J6/it/qCBPYIRGwfHyp5tJZoY7qY457Lg== X-Received: by 2002:aa7:8348:: with SMTP id z8-v6mr5321776pfm.81.1541030116256; Wed, 31 Oct 2018 16:55:16 -0700 (PDT) Received: from desktop.lan (astound-69-42-16-32.ca.astound.net. [69.42.16.32]) by smtp.gmail.com with ESMTPSA id b2-v6sm4128206pgh.85.2018.10.31.16.55.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Oct 2018 16:55:15 -0700 (PDT) From: Rosen Penev To: openwrt-devel@lists.openwrt.org Date: Wed, 31 Oct 2018 16:55:14 -0700 Message-Id: <20181031235514.22454-1-rosenp@gmail.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181031_165528_696336_07929E80 X-CRM114-Status: GOOD ( 15.19 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:441 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (rosenp[at]gmail.com) -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [PATCH] tools/patch: Add fedora patch for crashing git style patches X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org https://lists.gnu.org/archive/html/bug-patch/2018-10/msg00000.html I assume a CVE number will be assigned soon. Signed-off-by: Rosen Penev --- tools/patch/Makefile | 2 +- ...rror-handling-with-git-style-patches.patch | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tools/patch/patches/040-Fix-error-handling-with-git-style-patches.patch diff --git a/tools/patch/Makefile b/tools/patch/Makefile index 7323b5b2ab..cab9fee9f6 100644 --- a/tools/patch/Makefile +++ b/tools/patch/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=patch PKG_VERSION:=2.7.6 -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_CPE_ID:=cpe:/a:gnu:patch PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz diff --git a/tools/patch/patches/040-Fix-error-handling-with-git-style-patches.patch b/tools/patch/patches/040-Fix-error-handling-with-git-style-patches.patch new file mode 100644 index 0000000000..8d65ffe925 --- /dev/null +++ b/tools/patch/patches/040-Fix-error-handling-with-git-style-patches.patch @@ -0,0 +1,58 @@ +From 424da221cec76ea200cff1fa9b08a6f3d94c28a7 Mon Sep 17 00:00:00 2001 +From: Lubomir Rintel +Date: Wed, 31 Oct 2018 16:39:13 -0700 +Subject: [PATCH] Fix error handling with git-style patches + +When an error is encountered in output_files(), the subsequent call to +cleanup() calls back into output_files() resulting in an infinte recursion. +This is trivially reproduced with a git-style patch (which utilizes +output_file_later()) that tries to patch a nonexistent or unreadable +file (see attached test case). + +* src/patch.c: (output_files) clear the files_to_output list before +iterating it, so that recursive calls won't iterate the same files. +--- + src/patch.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/src/patch.c b/src/patch.c +index 0fe6d72..dfee378 100644 +--- a/src/patch.c ++++ b/src/patch.c +@@ -1938,8 +1938,12 @@ output_files (struct stat const *st) + { + gl_list_iterator_t iter; + const void *elt; ++ gl_list_t files; + +- iter = gl_list_iterator (files_to_output); ++ files = files_to_output; ++ init_files_to_output (); ++ ++ iter = gl_list_iterator (files); + while (gl_list_iterator_next (&iter, &elt, NULL)) + { + const struct file_to_output *file_to_output = elt; +@@ -1957,8 +1961,8 @@ output_files (struct stat const *st) + /* Free the list up to here. */ + for (;;) + { +- const void *elt2 = gl_list_get_at (files_to_output, 0); +- gl_list_remove_at (files_to_output, 0); ++ const void *elt2 = gl_list_get_at (files, 0); ++ gl_list_remove_at (files, 0); + if (elt == elt2) + break; + } +@@ -1967,7 +1971,7 @@ output_files (struct stat const *st) + } + } + gl_list_iterator_free (&iter); +- gl_list_clear (files_to_output); ++ gl_list_clear (files); + } + + /* Fatal exit with cleanup. */ +-- +2.19.1 +