From patchwork Wed Oct 20 08:43:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1543755 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=FofIkFJ/; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::103a; helo=mail-pj1-x103a.google.com; envelope-from=swupdate+bncbcwivbv7sugrbkvnx6fqmgqebtxybcq@googlegroups.com; receiver=) Received: from mail-pj1-x103a.google.com (mail-pj1-x103a.google.com [IPv6:2607:f8b0:4864:20::103a]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HZ3zj5B9mz9sR4 for ; Wed, 20 Oct 2021 19:43:27 +1100 (AEDT) Received: by mail-pj1-x103a.google.com with SMTP id z23-20020a17090ab11700b001a070e36178sf1416311pjq.3 for ; Wed, 20 Oct 2021 01:43:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1634719403; cv=pass; d=google.com; s=arc-20160816; b=wEL2ccesKHKH4A0blcyZr2TKqMFucaNt8Gt9mhd4RXTF5XOja+KkaSs6wBFZdPTNtq d7V9/nv7nUDLwTXNxh3v95I8dU4F3YaJailmfM57NBSNg5EXTbsPScMzq6wQ7zlwftVP xHpgHEPVG9E1qYRt8tpAZEmiOrKyOKRo5IEJmK8JsmgIem3KqZ7h04E0yyZolJN7pP6V 9SR2JRPVG/REQwEu9LUBiWmzvgriGhYgsWjWDtLNhLe6N5MhRJdxtyYCRJwngLZq/qI7 hEuRD/1f5355r/Ps2Fbv0jSLEvPgBFnJrq6lf0/0c0/KkmsEoIs0IkTWdMh1IijqxNc9 oaBA== 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=0FcgVMiVHzNWsQvhW6pfz4oWU3AKc9CYQ3XIernPNoA=; b=FMWTU1B1VZ04o3/3fB7405JbQO9evQEKboHDWY2c9/1v3VQUtkX6rfrsnmH6IqHsWN xljOLb1atfGqPDxOVaAVczw0l6Ar+wrIqG/OLqs7+54nSvcfbHYfYR177Q1ChRd9tthk ZfHH1RdTZ4oP1TiSoecpTNjIoHwwCXghGrdtJ/uAj7NyFxHRa6AaROkBeiU8IUGnSXzW 1/KUbAsQN7i685XAGnKbWxN/ll8WaayQs3ucDpEIFUNRQAg4L0BWDJPvL+ARiF9fMW/o NJ1/Y0iOUOMYWqqiAnkJsnAtjecEIxoS7DN40Kq7y54oomGw5+YoTO4Y+jcK5jAKVlIw M8EQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; 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=0FcgVMiVHzNWsQvhW6pfz4oWU3AKc9CYQ3XIernPNoA=; b=FofIkFJ/az6J2IoO0kJJsnhw91WMb2oJ/JYckxEfJXU0ySCqmzRRKlW7RS2vD1WwD1 jJw0pzgVLgf1SSllKViI/2cI8jpyZWIKmnOKZXkIBqhY6xr6fhQPHgjwsDR6Bef0iWRm 4OGzH2anonHe3LbhJOeV/02bk8tkDWcIYf2HzkQ43wTdX29uM/MFXCu15vJaVgsXjLOY 9PDza4s74qWRXviTEj3HHQkvx7BxJi+giHARAWaY+h8CgoauG9vRSlPD1sN+8JxpX6XJ pQeiqiGtn6+C8KlnLa3JPROJ4OhYp7Ws+H+DG9s9yKma+3ucHZZsjlyUUMmzPX6uD6lF dh9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=0FcgVMiVHzNWsQvhW6pfz4oWU3AKc9CYQ3XIernPNoA=; b=XQkhGRI5vQlAfKBRNc77pt0cti5jiBdq3cFHP+NVvWNV7a4uEzz6CzqsF4Y512S74b 20SzFlIVQUPMAPNZ7Lw4ijUgKHczcxP738+Bbjr4bZ4TlkH6kABA/LgYEuULUF1M2Chy +NnpK0CnaZMFdRElIQsF95k//rBYGKXvv/MmNbwI5W0pylvFBFCEB3wN1ZSWbVLYQ24A KnEXSamSqFqa1sB4+Vvh0k6jay5VZ4UxVtr93Yp+m8B5PgLhC3uorDzSqJs4x0Su4pVF RCl9rlGT5UN2IV8sFsSUYEp+I4WAthUB7DDkpH8rrFvzXikj09gzazA7K1ZzqXKvy7ni fZnQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532fLZztcxzW1QJoBW8lSyBdhBtiDMbaQAHAnatJ50yCwc6HY7ZI u2i3v9LIRaLcWGpqsXdQ9b8= X-Google-Smtp-Source: ABdhPJx0/oHL44BtGXtvO0ZLa4MjDdGbvWsAEF1jcnb+ztg+VImMLFnAqv1VasOkZzXpiNca8QJWJQ== X-Received: by 2002:a17:90b:1a87:: with SMTP id ng7mr5946110pjb.69.1634719402645; Wed, 20 Oct 2021 01:43:22 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:902:c40f:: with SMTP id k15ls1092933plk.2.gmail; Wed, 20 Oct 2021 01:43:22 -0700 (PDT) X-Received: by 2002:a17:90a:b382:: with SMTP id e2mr5867319pjr.119.1634719401916; Wed, 20 Oct 2021 01:43:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634719401; cv=none; d=google.com; s=arc-20160816; b=RNpU/K5/fzhJ/HaqMBp3NtxMqkQWHzZZ2D9oeLvyqZnTmUtgrIRIun0qSIVSo02RIQ CJb7IGI/tMI4uOosv41VL99AXy8VL9Cy3hYhBGBNBIZ7nvwk9CwRlj37A5AyhKjp0op6 7dDJf4K34eXlAAypuHMa6Baa+BjTcHWYnq7FIINChLda8iCwWJ+ouEDUs9bz1nXlZjhy WDuvU2gGVYBJ71NDl99MmkvzHkpGjeoZPhes/se4xRskfox9OPOk7zkXNBXN7D12acaI Kwj6Ra2884mx6adHpkcJFB5yoznEKi3b2ORHmm+lGE+JFpo4RGzSWCud9YhbBQvOkHXi Wlcg== 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=Nw37KsIa5vUZ+NuPvUrlMiEVdB2xXViP8JF13QLPEao=; b=aFCTeUDS0i/dxF2N8qRM9obQpoegMPV1FWTKJVxRyPtfiL6XjPP8mLp9kTKvRAkxs1 mfXOw9yMEiPAxOeFnS7WB+/+81h6KoWbbZOClFoE8dviyt9iya5SN01viVXO0f/t8NDM 7sxfLT+VX3KK7ofkVpYMLe2/Bx1bCym15ro1+Egr+bfr2rhX6p136e/qatLXXEJMGa/D OoAMR8vqEVY+i8rfPGmHDFMw5arWgxnMCE0YFLxX+uVM4wyxXycSiuJabEwqRfqFSMtF E0ph9IXpD4gBtcUusBEdC2sCJXaYOQPAYFJVOzfcBDNkRSDiOJmDQChgoeZlmN3uEdMH eEWg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) smtp.mailfrom=dominique.martinet@atmark-techno.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTP id v8si103638plo.3.2021.10.20.01.43.21 for ; Wed, 20 Oct 2021 01:43:21 -0700 (PDT) Received-SPF: pass (google.com: domain of dominique.martinet@atmark-techno.com designates 35.74.137.57 as permitted sender) client-ip=35.74.137.57; Received: from gw2.atmark-techno.com (localhost [127.0.0.1]) by gw2.atmark-techno.com (Postfix) with ESMTP id A802720CEA for ; Wed, 20 Oct 2021 17:43:20 +0900 (JST) Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by gw2.atmark-techno.com (Postfix) with ESMTPS id 9366C20CEA for ; Wed, 20 Oct 2021 17:43:20 +0900 (JST) Received: by mail-pf1-f199.google.com with SMTP id k84-20020a628457000000b0044db4128ea4so1504665pfd.20 for ; Wed, 20 Oct 2021 01:43:20 -0700 (PDT) X-Received: by 2002:a63:7055:: with SMTP id a21mr26683368pgn.338.1634719399652; Wed, 20 Oct 2021 01:43:19 -0700 (PDT) X-Received: by 2002:a63:7055:: with SMTP id a21mr26683361pgn.338.1634719399367; Wed, 20 Oct 2021 01:43:19 -0700 (PDT) Received: from pc-0115 (162.198.187.35.bc.googleusercontent.com. [35.187.198.162]) by smtp.gmail.com with ESMTPSA id kk18sm1771907pjb.8.2021.10.20.01.43.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Oct 2021 01:43:19 -0700 (PDT) Received: from martinet by pc-0115 with local (Exim 4.94.2) (envelope-from ) id 1md7Bt-00BHAZ-9L; Wed, 20 Oct 2021 17:43:17 +0900 From: Dominique Martinet To: swupdate@googlegroups.com Cc: Dominique Martinet Subject: [swupdate] [PATCH] archive_handler: fail update on more archive errors Date: Wed, 20 Oct 2021 17:43:15 +0900 Message-Id: <20211020084315.2687562-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 35.74.137.57 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: , Do not mark update as successful if archive could not be extracted! Current archive handler does not fail update when FS is full and cannot be written to after archive_write_header() or archive_write_data_block(). libarchive is nice enough to return ARCHIVE_WARN when the error is not fatal, but unfortunately inability to write a data block is returned as a warning so the write functions treat anything non-OK as an error. Trust warning status for read functions and only print a message in these case as we used to do. While we are here add entry name to error message when it makes sense. Signed-off-by: Dominique Martinet Acked-by: Stefano Babic --- Stumbled on this on testing and was surprised swupdate didn't fail the install, as I rebooted into a filesystem with some empty or missing files... I honestly have no idea what is warning and what isn't -- when I reproduced this for this patch, failing to create a file returned as ARCHIVE_ERROR so complete failure, but failing to append to an existing file is apparently only a warning, this does not make sense to me... I also couldn't get it to error anything in case of mode application failure (e.g. trying to extract an archive on a fat filesystem), but at least this mean that I didn't break this usecase -- that'll still work as before. Thanks, Dominique handlers/archive_handler.c | 46 ++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/handlers/archive_handler.c b/handlers/archive_handler.c index 8ee69ffdba78..ced7554125b1 100644 --- a/handlers/archive_handler.c +++ b/handlers/archive_handler.c @@ -40,7 +40,7 @@ struct extract_data { }; static int -copy_data(struct archive *ar, struct archive *aw) +copy_data(struct archive *ar, struct archive *aw, struct archive_entry *entry) { int r; const void *buff; @@ -55,12 +55,20 @@ copy_data(struct archive *ar, struct archive *aw) r = archive_read_data_block(ar, &buff, &size, &offset); if (r == ARCHIVE_EOF) return (ARCHIVE_OK); - if (r != ARCHIVE_OK) - return (r); + if (r != ARCHIVE_OK) { + if (r == ARCHIVE_WARN) { + WARN("archive_read_next_header(): %s for '%s'", + archive_error_string(ar), archive_entry_pathname(entry)); + } else { + ERROR("archive_read_data_block(): %s for '%s'", + archive_error_string(ar), archive_entry_pathname(entry)); + return (r); + } + } r = archive_write_data_block(aw, buff, size, offset); if (r != ARCHIVE_OK) { - TRACE("archive_write_data_block(): %s", - archive_error_string(aw)); + ERROR("archive_write_data_block(): %s for '%s'", + archive_error_string(aw), archive_entry_pathname(entry)); return (r); } } @@ -141,8 +149,8 @@ extract(void *p) if (r != ARCHIVE_OK) { if (r == ARCHIVE_EOF) break; - if (r == ARCHIVE_WARN ) { - WARN("archive_read_next_header(): %s '%s'", + if (r == ARCHIVE_WARN) { + WARN("archive_read_next_header(): %s for '%s'", archive_error_string(a), archive_entry_pathname(entry)); } else { ERROR("archive_read_next_header(): %s", @@ -155,17 +163,21 @@ extract(void *p) TRACE("Extracting %s", archive_entry_pathname(entry)); r = archive_write_header(ext, entry); + if (r != ARCHIVE_OK) { + ERROR("archive_write_header(): %s", + archive_error_string(ext)); + goto out; + } + + r = copy_data(a, ext, entry); if (r != ARCHIVE_OK) - TRACE("archive_write_header(): %s", - archive_error_string(ext)); - else { - copy_data(a, ext); - r = archive_write_finish_entry(ext); - if (r != ARCHIVE_OK) { - ERROR("archive_write_finish_entry(): %s", - archive_error_string(ext)); - goto out; - } + goto out; /* warning already printed in copy_data() */ + + r = archive_write_finish_entry(ext); + if (r != ARCHIVE_OK) { + ERROR("archive_write_finish_entry(): %s for '%s'", + archive_error_string(ext), archive_entry_pathname(entry)); + goto out; } }