From patchwork Mon Apr 12 01:27:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1464928 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::93c; helo=mail-ua1-x93c.google.com; envelope-from=swupdate+bncbcwivbv7sugrbhwez2bqmgqeonowayi@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=qLrJM2lK; dkim-atps=neutral Received: from mail-ua1-x93c.google.com (mail-ua1-x93c.google.com [IPv6:2607:f8b0:4864:20::93c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FJWMR65b1z9sVt for ; Mon, 12 Apr 2021 11:28:02 +1000 (AEST) Received: by mail-ua1-x93c.google.com with SMTP id r6sf409174uaw.17 for ; Sun, 11 Apr 2021 18:28:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1618190878; cv=pass; d=google.com; s=arc-20160816; b=FGqcdZVGSNziWooW4rVBVlZpcYdJP4Fo11v3m5MWNa5Fg3XX2098fuRn6kdDjvXPvt kA+kGuagINCcRt7isAt/yr8OizDXFwhgUEpmJV4GhpohpztBBlFJ8OeVUgWUePyqHKPn j6DEZpQ2bwta4kVFFI9GK/kgjOzMzjbhnZ9tvhYTRT5JLZ6QHP27suGMruaLBLD6oCJv ao3uNQSGniZn8RgA+rpZ9smq2nPPQvWwO1ANy1jNkRK/dx6iUKwYgKOBhJHXznKghQ0i zm8zR0ij1EuxJ5/YaDDk3VUCvLM8LiwObj5zSvaUR7iIvK3+0Rj/jNgZGXdml5o+zaF2 R7zw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature; bh=QTlhjHt0Z0BdeQ/y0cgQh6aQKs+9kk9DS9qUBULYPA8=; b=szMeBlG5JrYxQHeYXscNXWalDNXJwTsnF5JJSd8hGi4LnVjwrrSNwJa/5qmqQ4T3QP bvj4kzFYNtOjFTGEFi6VUXuKyBFUS8Qb8U0D+rMc8L6O0MWv8+gxcZ9AcvHTAJmzIEDl zORXh1tDXbPSvPUigOrYyvMGjo3PBAAY1SAf5nJlDufBI+HfhZqEoHWd8GM4WJj8ge9T uPcoeKtP1RTxI+f/RWHf62HTo6M+OH59DtrKJZSBcKz4nAO2/C6cYe7/tD4iQ9L7mXUc uPrzGYuuOm8A1DM+AKm4jgsVAX2rcxNIpXJbrBWG2R3Fzk1cvYvxnfxAB3KqTmFhfKOU Doiw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 13.115.124.170 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=QTlhjHt0Z0BdeQ/y0cgQh6aQKs+9kk9DS9qUBULYPA8=; b=qLrJM2lKAhI5v5jqLulxnQjek3+AvT/cP2VcXYRtYxXLvggReSm3EY0srJdpFYnAPe Ar+v7g0vGKEE1pGdbGCkNDnRW5hjhHSew4lWOqi5KajFW1mceg9+m0dUWeW2W6URiRbW 673vIJdsvN+cSzHkA8sI1+QrAjFq4ZXZDDkMH5JSbx0RiO6M7znwl1z9kzq5wcNdSc5Z f7cv1j897ezWNRUkJfwXnGWP7IQ+Zx2I860qJ6ykmR0RTUEcofFridXafrcMfvBt1x3T AY02p973H6YXRkQd5EUw5lr2+MqN/5PFJzpRMEZFF3jGboNkZYRdML7aUDUrJaiJ5PlG 2rOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=QTlhjHt0Z0BdeQ/y0cgQh6aQKs+9kk9DS9qUBULYPA8=; b=dLd0uUDbROLVtUpfZKDFTu8dtqm1dXtzj6uMnt2CJieYVRYoVhb+cNQ2H5ZEiswPnq 8gGFYyJls3vyJm5tyR+l4XdKtM2pR1JUDgBLam0CIn+fKLl/m8fbU4N5IlbkNAkasTmX sy3M2HiY4W23yadEsfrAlGA/k4gYcOxl5fiErAMdtqRtgoH0ecgpixnq9dvdoOM7Z/ch bSqH5svHz8rN8J2xhNhLVSZRRyPWBdnmcCFebpZ3KXgTQQfvVzorCLRvNsh/GxvJj9ga j9jSPrypp8QpjMh7IOoUgt3P76qMat+jqg7kDwnoH9jfUspvBgtCc0Jz+h9RzRnESAY5 M2vA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531sfJ7FVW4q77zb52N67LkpRDVHCWEag+lQhA6b0T+2cmypPtXU hdsgG5DkhGFz+QUUB9w32qk= X-Google-Smtp-Source: ABdhPJyBhnh7QLr3Rtv+C6VTrN9C1ubDgINTFomgzVJUSiIZQL5bAKl2HxVcESyHt9sCLWyCC4gjrQ== X-Received: by 2002:a67:8007:: with SMTP id b7mr17439373vsd.29.1618190878579; Sun, 11 Apr 2021 18:27:58 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6122:2164:: with SMTP id j4ls1005151vkr.7.gmail; Sun, 11 Apr 2021 18:27:58 -0700 (PDT) X-Received: by 2002:a1f:1d46:: with SMTP id d67mr7247061vkd.4.1618190877976; Sun, 11 Apr 2021 18:27:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618190877; cv=none; d=google.com; s=arc-20160816; b=h1RjhMwMlhpdWDqbQaAoVzBEtRnuEvjQ+O4BRNVcO4Z10/0A3jEkDt48NURoyMNdJu 3sZDqfi0QGSKf8qD/fynjslf7IEzFbNO/feg8UTO5cyO8EaQelkEVVIdtE9ZpJAbHgEf dL4R4+i4ZGeBGS5tpYg5hWXNtHQnPfcGo3+CGd4GYyKoYH6wp0Iim8p4bBoL5Qsnr5rO egeaWPvMC8geghz5cWoMhN5x/qIfolEAxHcfl0eQbdhGL+VqPNxheyM5nK6SNLpO90uX vNOq0Tj1v9Ih0yY8BpIBLX18/pGocUBgmV3AMYKcAerZiELmz3GSS5/EJToUTFSn2LQz tTCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=GBUG890LEVyiUu71uJPI9QHwwa3SvIX6gdjkw8uZN4s=; b=W/A6yrAvTmMrU7psYKSXH9MMnM1a9LnIhm8kd4Imo2rJWh2Bks+r9w+gHXE7C4EepQ kufSBBSHTi4UqWFO+CNS74qF/pDuHgdR1slvq5g3dhENL0kERlzEocJBBsuaV/eGgbMO CFhwQ06keZaKCdP6xHK8ISD0EOQXUo7PngU0BvypvsNwYLBfN8xdVM0iKW8PNtrhEfI0 OlCQolcwd2S1frcYtlkSZBk1tVdiPjnLj0iAh1pv/P9Jmf6hC/bJ8tvrMM5LsWwjej2n otdoOXJCf3kKi/KEmuBh9EQrWQOyfNPB1vMuePiT5VzpC4R8yo3aX1zjl00ovlu36K+L GuYA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 13.115.124.170 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Received: from gw.atmark-techno.com (gw.atmark-techno.com. [13.115.124.170]) by gmr-mx.google.com with ESMTP id r17si576197vsf.2.2021.04.11.18.27.57 for ; Sun, 11 Apr 2021 18:27:57 -0700 (PDT) Received-SPF: pass (google.com: domain of dominique.martinet@atmark-techno.com designates 13.115.124.170 as permitted sender) client-ip=13.115.124.170; Received: from gw.atmark-techno.com (localhost [127.0.0.1]) by gw.atmark-techno.com (Postfix) with ESMTP id DE40A80453 for ; Mon, 12 Apr 2021 10:27:55 +0900 (JST) Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by gw.atmark-techno.com (Postfix) with ESMTPS id 9C05880453 for ; Mon, 12 Apr 2021 10:27:55 +0900 (JST) Received: by mail-pg1-f198.google.com with SMTP id w8so5329157pgo.23 for ; Sun, 11 Apr 2021 18:27:55 -0700 (PDT) X-Received: by 2002:a05:6a00:1651:b029:241:afa4:92b1 with SMTP id m17-20020a056a001651b0290241afa492b1mr22571687pfc.12.1618190874148; Sun, 11 Apr 2021 18:27:54 -0700 (PDT) X-Received: by 2002:a05:6a00:1651:b029:241:afa4:92b1 with SMTP id m17-20020a056a001651b0290241afa492b1mr22571678pfc.12.1618190873969; Sun, 11 Apr 2021 18:27:53 -0700 (PDT) Received: from pc-0115 (145.82.198.104.bc.googleusercontent.com. [104.198.82.145]) by smtp.gmail.com with ESMTPSA id s15sm9539506pgs.28.2021.04.11.18.27.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Apr 2021 18:27:53 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.94) (envelope-from ) id 1lVlMm-000UZg-9Y; Mon, 12 Apr 2021 10:27:52 +0900 From: Dominique Martinet To: swupdate@googlegroups.com Cc: Dominique Martinet Subject: [swupdate] [PATCH] raw file handler: add free space check Date: Mon, 12 Apr 2021 10:27:50 +0900 Message-Id: <20210412012750.117483-1-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Original-Sender: dominique.martinet@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 13.115.124.170 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Check for free space before writing file in raw file handler, to avoid needlessly filling partition. This reuses img_check_free_space which checks decompressed or decrypted size attributes if available, but will fallback to cpio size if not set Signed-off-by: Dominique Martinet --- Follow up on https://groups.google.com/g/swupdate/c/hLK4jAIsC-g/m/pimR8Pl9AwAJ We probably also want install raw file to check in final destination, and not just protect /tmp Tested with installed directly and without. handlers/raw_handler.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/handlers/raw_handler.c b/handlers/raw_handler.c index 14005717d950..17e1c2c3a4aa 100644 --- a/handlers/raw_handler.c +++ b/handlers/raw_handler.c @@ -253,6 +253,10 @@ static int install_raw_file(struct img_type *img, } fdout = openfileoutput(path); + if (!img_check_free_space(img, fdout)) { + return -ENOSPC; + } + ret = copyimage(&fdout, img, NULL); if (ret< 0) { ERROR("Error copying extracted file");