From patchwork Thu Jan 4 14:02:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 855602 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pP0aOpGh"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GHs1HkYj"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 3zC8dT0wn0z9t20 for ; Fri, 5 Jan 2018 01:02:50 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=vkBfjOu7XeWYchnMts3Yj6TH4fqSYk1VXDvBa4n8Hpk=; b=pP0aOpGh8CskXl J1UhstGIv0SKu635EKWXGImrFYI4/Ror7WKHciE/Q6tozBpD0w9+K2cT7YUdpVfh6O79087fxUVon X6echsNxSC5x6YhvGPIVRAffE/F9EnFutdUHYfM4Bk1UpZ+JW+CWLd5d8maEFPWAld/dufSkCwA2O 9GqEpIeCcauMtb8+6IRb/57+Gve/pKl0cb7lH719WYIPZlcP+R9td2aDWeRYXChDhQP1NWbCMQIP4 XgafWD75OFn1jaLUAz0KRUQIje47E2xGWFegJ0elSsNaSi5IA5gd1JRZRPyVq4iKxiHopPrPhsDhp kNkSD/fcZZSzIbaH9mGQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eX66Z-0005cB-Rs; Thu, 04 Jan 2018 14:02:47 +0000 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eX66V-0005Zy-8I for lede-dev@lists.infradead.org; Thu, 04 Jan 2018 14:02:45 +0000 Received: by mail-lf0-x243.google.com with SMTP id o26so1856057lfc.10 for ; Thu, 04 Jan 2018 06:02:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=klooXyplIXYuBaGPD3F/ndLYEMHCvAyKw4BuaK5soPE=; b=GHs1HkYj41ORtZf35UEG6iKe0r//R+um7szJFvsOeFQFesaJsaOq6kw2KNkGyLxamn h0d8Y8yojNB4vetirRw/IXHbbeDgDdHQUoj2AlC1uHelgiSVrXEIKHugstuFUgpbBTPY dilsI/dhSS/y7CBtx/egJ5K/OwwbeR79LQ8ocxyHPUxFqmsOL8U6kvLOrDJXEyGPPJAr ZQguSWdYcWz6K33ypkyk9En98MIFKvCAL7scrh4WIqBw71VEVuYo+8pXR9m7m0BT2X01 aLuUE397PAVWb4WPPqxEo8Sbo9TVCxqhkhcNr/YphKBo2Ty16ZRiVH8lMYVHT3YNkbFO E37Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=klooXyplIXYuBaGPD3F/ndLYEMHCvAyKw4BuaK5soPE=; b=ZIYZePbNYCjYIqQrXz9EzQQlEBJYgFFqgQ+sM2JQDsz8x8Q3fpYkZfJwTgc00Ca6z2 SM9gtXnj0Mk3LhmlAqF3hqqMi8lL4YLpyfI47UVO+IRnhbgb9yIuRqcDN441cAitbnZs 0cAw/qT552cbbRZygMq4DhgT4JH9KmvV0NuixR2vJ51yJX7zFtpzkLBDfxQO9pNRAI9O bFFDW79/tPStYBBlDT+Vdh4fyShXlngq/N0KltNqWAXwZFlpsy12j0RSGlRTrtIntpfQ kMztcATfzqQU62VuHeGF/QwipPXFcsfO1UmpTVpShHlV9mM22A4pOTPj0wgsiq6djtL0 3HVQ== X-Gm-Message-State: AKGB3mLQSbG8/L5R5zWpQNW7hdkYnYbQA8zUXs2aDqO7mvzJL+yrgxBC amSdbhT5uIxkj3kcdgu/JV0= X-Google-Smtp-Source: ACJfBou7s6cBWnuMPKfnijitaOujzc7KNnGtnbnhKNAs2YzCoBrbY9QH1EEQtGcguryjcwq8uuJItQ== X-Received: by 10.46.32.7 with SMTP id g7mr2837260ljg.49.1515074550988; Thu, 04 Jan 2018 06:02:30 -0800 (PST) Received: from linux-samsung.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id f67sm647298lfb.90.2018.01.04.06.02.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jan 2018 06:02:29 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: John Crispin , lede-dev@lists.infradead.org Date: Thu, 4 Jan 2018 15:02:23 +0100 Message-Id: <20180104140223.4649-1-zajec5@gmail.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180104_060243_394091_66349F6F X-CRM114-Status: GOOD ( 10.26 ) X-Spam-Score: -1.8 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4010:c07:0:0:0:243 listed in] [list.dnswl.org] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (zajec5[at]gmail.com) 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (zajec5[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Subject: [LEDE-DEV] [PATCH] libfstools: support file paths longer than 255 chars X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Rafał Miłecki Alloc globdir buffer dynamically and simply use realloc when needed. This fixes e.g. segmentation fault in jffs2reset due to an infinite recurrency when dealing with longs paths. Signed-off-by: Rafał Miłecki --- libfstools/overlay.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/libfstools/overlay.c b/libfstools/overlay.c index 8423a57..a7c4f02 100644 --- a/libfstools/overlay.c +++ b/libfstools/overlay.c @@ -67,15 +67,28 @@ handle_rmdir(const char *dir) void foreachdir(const char *dir, int (*cb)(const char*)) { + static char *globdir; + static size_t globdirlen; struct stat s = { 0 }; - char globdir[256]; + size_t dirlen = strlen(dir); glob_t gl; int j; - if (dir[strlen(dir) - 1] == '/') - snprintf(globdir, 256, "%s*", dir); + if (dirlen + 3 > globdirlen) { + size_t len = dirlen + 3 + 256; + char *tmp; + + tmp = realloc(globdir, len); + if (!tmp) + return; + globdir = tmp; + globdirlen = len; + } + + if (dir[dirlen - 1] == '/') + sprintf(globdir, "%s*", dir); else - snprintf(globdir, 256, "%s/*", dir); /**/ + sprintf(globdir, "%s/*", dir); if (!glob(globdir, GLOB_NOESCAPE | GLOB_MARK | GLOB_ONLYDIR, NULL, &gl)) for (j = 0; j < gl.gl_pathc; j++) {