From patchwork Mon Jun 17 07:29:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1948523 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=t3Sjq7V+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::33f; helo=mail-ot1-x33f.google.com; envelope-from=swupdate+bncbcwivbv7sugrbtolx6zqmgqejmmi5ty@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-ot1-x33f.google.com (mail-ot1-x33f.google.com [IPv6:2607:f8b0:4864:20::33f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W2hNM5Hnmz23tx for ; Mon, 17 Jun 2024 17:29:36 +1000 (AEST) Received: by mail-ot1-x33f.google.com with SMTP id 46e09a7af769-6f9866bd6d6sf4969611a34.1 for ; Mon, 17 Jun 2024 00:29:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718609358; cv=pass; d=google.com; s=arc-20160816; b=TuL/DBfI3FOq573Lt9HhPjlW8LQUMuz5JQ8/3toUbt48SjyDJvvfSlV9w/eJ3SJTvP ClWhE/UcnYOHaM4o9T4lhHhhWMseyGzzR7+v9zfsjYljARVdR2+aXztPZR3LsdeKcE4q OXSIv9DzGkDf+N/m6P93+RIaS6ZwbILbs+MOogl6RDq3eQN2aecU/MQo63qevh1UY6R/ BjEoDN6Ee5QXa402qSWLt1JkPwwXFHmYJbvl6i/KBvO2r1lzgJcQJpBfTLt2e4M4NNWj nBK6LQBJW2MRZ7abXww1TbWLm5iPalHY3czRhOW/5y1HN5sgm//KOflqXJcbOZU+CcGc BVUw== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=Dkk2oBOMwWJM51MS8H601huS8A0MEJ8YI8m5plvazG4=; fh=mhzrxU8dmc8DxbNUWyCvCWwKJxWW14+qnJUJSqtI54g=; b=wDF/xyQ53SQLPJUjAret+xQd1/wi4bt3UqCGcCwH1HI6dItLTAJ92pxXHpj7zMh5+u 0o3vdNEWLxX5WV3eWn1OFgoIYKdHai2uZ1x4RijCfmRgHLGInJSw9cy1v9e6j4vtsHT+ mb82JtvT79XmkuTSIYN2INkMxNOZpiFLq2vhf8yIwav9fOw93sfwCmrkw/Jn8X2xs3rU d7t5lzy9S+tZr/erOl+y7RAvzmdqR/l8tNRyy1AtHWToBCvKsYnfCUpVv43cij/d23+m nWQZ5qkt6WOuAsEK/kfqhaOZ1ujGXSSNuup14aj2OZQ/uO0Ipy7NZnJT5j+6WsjmvNo+ wqbw==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b=RHnyk56G; dkim=pass header.i=@atmark-techno.com header.s=google header.b=Z135yh0Q; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=atmark-techno.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1718609358; x=1719214158; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:sender:from:to:cc:subject:date:message-id :reply-to; bh=Dkk2oBOMwWJM51MS8H601huS8A0MEJ8YI8m5plvazG4=; b=t3Sjq7V+ks0TfwrZT13uhPv14KfpmCT90yPhlz9ai5nUrzzYy9m3L1Q3DnZdFQNY3j ahneRiewyEeh812HrFoSQTmmtiTN697f88bUtsbFUn2EK80wd8MYUdHYhT/wZTPqsScQ 9jmi51TtZ3TtZ3KdMSCeHm9eh51y4f5XLYZw3VRYdwTTfqoqvqfFdaswixubZmfKaKtx 6Kq6bwiqFC0zUmsKYNFVtgAUVh6zyspGNNQ8tVPPRftPlb/nzt9+pgp3+Qc1lIpfv0GR yo6gAfTyTztfgbEEXGhtpY88sj8Fe8yEy/Z05543yt3uDV9RY2dmVrEuhjZKc+V07QQv mH2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718609358; x=1719214158; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:sender:from:to:cc:subject:date :message-id:reply-to; bh=Dkk2oBOMwWJM51MS8H601huS8A0MEJ8YI8m5plvazG4=; b=uf+F8PyqhRL+yUdcrT1oafb5rrttxlzuQ9qZ/qt1U3ItyZ5i8itMIIBFL1fUUKFSVx wlhvgLOzNh9KpZaxx61Qh23okUiXDywBdOP5xyTVwpKXlOzWlBAHdK9QaumczNB1lYM0 tuIyN4KxEkH48mPx0sscg/4QRjCpmYiT8J2HLgNmoyuR6ipKxIniO+nqUeymUyac59Y0 5qRgidWgpbu2KZEpzktiAVK4jzqXpEwBf7pwPGPyoAfbBnSxRP/uGDUKJM3UEaLJ7Pen +euzrvXK13gIyJGSxLu+iPiNoSeEeF0M/hh4Col82ml9sb3su0Q5UW/0gXfb9LWX7+tC SyPA== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCWlPLdagrV/DTo0gpiTn8mQPNDIKAeDOp58QPJC4yE+JVSu2CdyNTlhq+WjsLL8pErqy49Hd5mIUx7FmSUXfimF4HsRRhIZhoUtXbCx6A== X-Gm-Message-State: AOJu0YzlrVf5cZPL6+R5m8Tzr0uCWBWHY8mG9ftfJaYSIg9hcyvBNTiA UGyl+Rbr+Q//QP9ir/GFprou+aMA88OpuToo4ex2XVVnYffafCVd X-Google-Smtp-Source: AGHT+IF6nlCoHonkyUlqS8gjVzTpyVPzIVeXGvQ1LG8WeWhP81lXBmZgncbb6ZIi47Svh/xETCDMCw== X-Received: by 2002:a05:6870:3906:b0:254:b2e8:163d with SMTP id 586e51a60fabf-258428b4e11mr10677283fac.19.1718609358279; Mon, 17 Jun 2024 00:29:18 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6870:718f:b0:254:6df2:beae with SMTP id 586e51a60fabf-2552b6aac4cls4137227fac.0.-pod-prod-04-us; Mon, 17 Jun 2024 00:29:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVAHQkJnLsmH/b0rwts5ck4sDfBU848IB7X61bGtoe07ZD+22WucuWjs2K8zjpj+GslM0IHKqJ/9zoYi3mBu/mUeorWddGFV4E1 X-Received: by 2002:a05:6870:5387:b0:254:d1d6:2ff with SMTP id 586e51a60fabf-258429a3affmr10429001fac.34.1718609356758; Mon, 17 Jun 2024 00:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718609356; cv=none; d=google.com; s=arc-20160816; b=pSvkIf7Otd9NFXT9V6S1YJf4bjl7g1Lxs5eREzqnCUq+vsj523bwtoeocTpJFuwMJ2 xPlwyICCUui//PzmWbxkxJuk2amKqLco8jNGvV3zHd6dBM87llicLDqz4T3ZiJGXr+S5 M85IY3sMb3mYYFiupiJQD7HsvEx5ob/r6X7zm0nnD0yWVZPLRBmd3vW1rPhxS3FW3U9h FcdNbR/YUCBU+WEMidsWmjdtrPxUW/vwDq4eqKDLVGg33Jv+I4gEcvVcjI2W7wwWtkyB 6nJsKLMzOMdwDYqQcYBRvMh6LPjB21pVT4ZiuwMnrIeN7vuDCnEn+z45sJCw0U/xDHwg 0t3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=W359nTpbI1Fk9qW+AIt/2jgo7M+eI255ymHh3tAJmZs=; fh=ILSOYzF5xatB7BPgosENgTurR+BSOxxoFiBnY+Qf/vY=; b=zMfKlMDWAX+xOffUr4Bvd0E153FKz17tRHTwfw1Yqj4L+sKfukUooO4buAVxpFMafP OvGg88lz3QXxwKwBgPJpcAfkdEl/s7eJuDNq2ZLETt8BuIPHmTB+Fcke9OupNEhttVZ9 MIKrgaxTLcqMXnKuYWtJSuAACBJWbnUL+g9jLc66a3UsOA2j+k0A64xEa5dbrUWAiw4c sAYBqcVbEoumg6vhgSW5/cAwZBl3MDlEgTgInAHzpQNdNobgYX/MxBMqCTLp5chf1wTn xn2fvfJFQ52aB9iYKLerjUokuOxo6C/Xh/RmDUiLjv4flMagdX8Pibj5H8eq7mzKnYFZ JhTw==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b=RHnyk56G; dkim=pass header.i=@atmark-techno.com header.s=google header.b=Z135yh0Q; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=atmark-techno.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTPS id 586e51a60fabf-25699377358si407669fac.4.2024.06.17.00.29.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 00:29:16 -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 712C4A6B for ; Mon, 17 Jun 2024 16:29:14 +0900 (JST) Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by gw2.atmark-techno.com (Postfix) with ESMTPS id A71C5A77 for ; Mon, 17 Jun 2024 16:29:13 +0900 (JST) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-649731dd35bso3480447a12.0 for ; Mon, 17 Jun 2024 00:29:13 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCXgetodJppceoUXIebF1wvSsY5W4q8iyqWhI4hRz2A4V5QREhLyJOkEy5DKt9FTskDEYVqFPL9i3xgFQj3XCy/okl92KBV+QTLT X-Received: by 2002:a05:6a21:191:b0:1b5:2fbb:2d78 with SMTP id adf61e73a8af0-1bae83c6280mr9178430637.48.1718609352663; Mon, 17 Jun 2024 00:29:12 -0700 (PDT) X-Received: by 2002:a05:6a21:191:b0:1b5:2fbb:2d78 with SMTP id adf61e73a8af0-1bae83c6280mr9178403637.48.1718609351813; Mon, 17 Jun 2024 00:29:11 -0700 (PDT) Received: from pc-0182.atmarktech (162.198.187.35.bc.googleusercontent.com. [35.187.198.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f855ee6eacsm74246965ad.179.2024.06.17.00.29.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jun 2024 00:29:10 -0700 (PDT) Received: from [::1] (helo=pc-0182.atmark.tech) by pc-0182.atmarktech with esmtp (Exim 4.96) (envelope-from ) id 1sJ6nd-009Y52-1I; Mon, 17 Jun 2024 16:29:09 +0900 From: Dominique Martinet To: stefano.babic@swupdate.org, swupdate@googlegroups.com Cc: Dominique Martinet Subject: [swupdate] [PATCH 1/4] parser: set_find_path: properly return to-free string array Date: Mon, 17 Jun 2024 16:29:02 +0900 Message-Id: <20240617072905.2275940-2-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240617072905.2275940-1-dominique.martinet@atmark-techno.com> References: <20240617072905.2275940-1-dominique.martinet@atmark-techno.com> MIME-Version: 1.0 X-Original-Sender: dominique.martinet@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b=RHnyk56G; dkim=pass header.i=@atmark-techno.com header.s=google header.b=Z135yh0Q; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , properly set 'tmp' through an extra indirection instead of leaking the string array Reported-by: gcc -fanalyzer Signed-off-by: Dominique Martinet Reviewed-by: Stefano Babic --- core/parsing_library.c | 5 ++--- corelib/parsing_library_libconfig.c | 2 +- corelib/parsing_library_libjson.c | 2 +- include/parselib.h | 2 +- parser/parser.c | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/core/parsing_library.c b/core/parsing_library.c index a97f8114becc..038c6851adf9 100644 --- a/core/parsing_library.c +++ b/core/parsing_library.c @@ -210,7 +210,7 @@ void get_hash_value(parsertype p, void *elem, unsigned char *hash) ascii_to_hash(hash, hash_ascii); } -bool set_find_path(const char **nodes, const char *newpath, char **tmp) +bool set_find_path(const char **nodes, const char *newpath, char ***tmp) { char **paths; unsigned int count; @@ -218,7 +218,6 @@ bool set_find_path(const char **nodes, const char *newpath, char **tmp) char *token, *ref; bool first = true; int allocstr = 0; - (void)tmp; /* * Include of files is not supported, @@ -301,7 +300,7 @@ bool set_find_path(const char **nodes, const char *newpath, char **tmp) } free(ref); - tmp = paths; + *tmp = paths; return true; } diff --git a/corelib/parsing_library_libconfig.c b/corelib/parsing_library_libconfig.c index ddb79f6fb152..4ddc338031a0 100644 --- a/corelib/parsing_library_libconfig.c +++ b/corelib/parsing_library_libconfig.c @@ -196,7 +196,7 @@ void *find_root_libconfig(config_t *cfg, const char **nodes, unsigned int depth) if (elem && config_setting_is_group(elem) == CONFIG_TRUE) { ref = get_field_string_libconfig(elem, "ref"); if (ref) { - if (!set_find_path(nodes, ref, tmp)) { + if (!set_find_path(nodes, ref, &tmp)) { free(root); return NULL; } diff --git a/corelib/parsing_library_libjson.c b/corelib/parsing_library_libjson.c index 4728d200fc8e..9456d51eca9d 100644 --- a/corelib/parsing_library_libjson.c +++ b/corelib/parsing_library_libjson.c @@ -237,7 +237,7 @@ void *find_root_json(json_object *root, const char **nodes, unsigned int depth) if (type == json_type_object || type == json_type_array) { str = get_field_string_json(node, "ref"); if (str) { - if (!set_find_path(nodes, str, tmp)) + if (!set_find_path(nodes, str, &tmp)) return NULL; node = find_root_json(root, nodes, depth); free_string_array(tmp); diff --git a/include/parselib.h b/include/parselib.h index 99b6519fa480..48f38d2a8c92 100644 --- a/include/parselib.h +++ b/include/parselib.h @@ -64,7 +64,7 @@ void get_hash_value(parsertype p, void *elem, unsigned char *hash); void check_field_string(const char *src, char *dst, const size_t max_len); void *find_root(parsertype p, void *root, const char **nodes); void *get_node(parsertype p, void *root, const char **nodes); -bool set_find_path(const char **nodes, const char *newpath, char **tmp); +bool set_find_path(const char **nodes, const char *newpath, char ***tmp); #define GET_FIELD_STRING(p, e, name, d) \ get_field_string_with_size(p, e, name, d, sizeof(d)) diff --git a/parser/parser.c b/parser/parser.c index 04d7b72c9b9a..2273796e0452 100644 --- a/parser/parser.c +++ b/parser/parser.c @@ -144,7 +144,7 @@ static int parser_follow_link(parsertype p, void *cfg, void *elem, for (int j = 0; j < count_string_array(nodes); j++) { linknodes[j] = nodes[j]; } - if (!set_find_path(linknodes, ref, tmp)) { + if (!set_find_path(linknodes, ref, &tmp)) { free(linknodes); return -1; } From patchwork Mon Jun 17 07:29:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1948520 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=bYRnauk3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::f38; helo=mail-qv1-xf38.google.com; envelope-from=swupdate+bncbcwivbv7sugrbtglx6zqmgqemgo3agq@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-qv1-xf38.google.com (mail-qv1-xf38.google.com [IPv6:2607:f8b0:4864:20::f38]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W2hN42ftrz20Wg for ; Mon, 17 Jun 2024 17:29:22 +1000 (AEST) Received: by mail-qv1-xf38.google.com with SMTP id 6a1803df08f44-6af35481ea6sf55118846d6.1 for ; Mon, 17 Jun 2024 00:29:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718609357; cv=pass; d=google.com; s=arc-20160816; b=Mpn1TAal2k2vFSn/Zp5W7O/X3Tnm1P4vIpDc0Aow42O8cXaSfBkJ5ctFDDUqyHZVb4 qaNDce4OfFY9R5R61l1vx8i8Aiu+2ll70G4lE1lC92VYLEM2HUYrjND0yZ7HSBmUdDf9 PE/OaXKueCjTZhmAcD9c+EY/07qF77x6+bfHRwEoRHgHNBbRpkWGTNWYhADRxkGtvAYN slk1y6SByDCe2X+uleXiVXMuIsO8q1Aawb/AWXZu2gEajYz7PMwoD1+UrECug2ecjBUH 9AqTX/VQF+Yfjzf/p72Vx0/LC98Tz6vBhb14TgZEq8Mn6voDEKrLoqWfStER2cwDBbjG fgVg== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=PNt4Q24gu9URlX4bX4596ykHcXTLY4z40TNwnotY4X4=; fh=TdA1r2DlbUHD9f5p/yJ5ZGIDPhU1nOuvz3n3p01moNA=; b=dcVzrcpr8tH1S2PcEfoNQwNjCWzlxQtUC8n9gCmqOwT9bSonY5pLNlwfbUUP6XCEao 93Zx2Q4fEO4h/ikSZtw+Ajl2gzTO3rp6282Xmrn5PeSmqly6AJedUqFRY91jXNipDxdq 2y8Zap+b3UQrj9V3mxoLB6n7R9gs9nDdVd9Hr6+uPKriwc5Zt7Px2kwPUuc3n5vxdLiz d7JkD39U4TFuuUS6M5IPn8090DQNFktN894hba2XiQKoH8PWjPYNbBJpBiIumxeXoEB/ L+o8BqUNJggXtpkKZub3CTJ/MDORYdgE2+L2VnyNRnoeD6gHUGJDsI0s5cR+4BII4CrO hw2g==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b=lZnRAL8P; dkim=pass header.i=@atmark-techno.com header.s=google header.b=H5qHeNFb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=atmark-techno.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1718609357; x=1719214157; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:sender:from:to:cc:subject:date:message-id :reply-to; bh=PNt4Q24gu9URlX4bX4596ykHcXTLY4z40TNwnotY4X4=; b=bYRnauk3B4jpAMMXYMep/+v4cjmoXyNe45u3jZmcX8phrsDjH4UKEhIZrhpSiaEo2a bvP9HKUciyO1N/qvbgc8ge+O509GuWyq46yf+3IASE3w/kZgEzJY9nWsZOaczReaeo5N nqJ0Q4iw2UsgGHjDAy6z+gOe2LzAsio4SyXf/q/Fjk0AHhokKkojBKdrzappAvej1+te onQbNPj4JJrpoDIzKd8Lra5/6bQOcQ74L6xJuJtvHGCIjipaBXgszKCyHfEdMwITFhcd DLBMSHoSz81XpTHM8sowyLsMFJhnmnORR4YOqG0OvugstiKWcoRw5r7whj40FQPcuVja Ahlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718609357; x=1719214157; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:sender:from:to:cc:subject:date :message-id:reply-to; bh=PNt4Q24gu9URlX4bX4596ykHcXTLY4z40TNwnotY4X4=; b=CqVF+lFQHTYH+2rt0FThiyyrm4JIZRZ7m3SatVtDOdmg7u9e+3j7lhP375zFsiBkMs SBSl8eGmr37dMWjMeXXsYIkVy1/2uQnHlWgJOd+nHcM2v7SCWaSQhLql5AxD+RZrGAM1 QAzVR+BPvtyiKVWwJg7ZvPRsAyxgG/ibMq4tXmtPsygjRaDujigZuPd/+P7dndc7uW8x 5E9uQMM7ktRodm8sHSz1DpcfzKpfwRy91qVlFt5UtlnZSgEarXdqcYm3MI7ZGXJNMXaC x9sRjVUC5ljJGbJToz0G42EZTVx7ii6lTTW8vKPrjPFQQ03LXacCfLRmsRC1dHFJX6FL 7Sgg== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCXFCPEH9XcgZhH5F1UzcSa+uNtsN3d86KK25uVLvq7UtDEuVC6vfsj5vGZ+4Rp+XaKTOEZSrFX+ZnlZ6lyMSqH9kK8G8fdslPEkjWKIRw== X-Gm-Message-State: AOJu0YwdS0KydD5t/dnSkc0kqoFTVMw/N8gOgOOWDxmctmPHRy9J6hl2 KmgOqRP8cwSP37IqZON95v2UNugqRvaYiDvqpUabZ1irngKu+EMZ X-Google-Smtp-Source: AGHT+IH7kVbY/v5cpgF8WHBTPCA2gCTH0woRk4g28p9wInkrAaNKRRQ+PN3wg6rjkRcfAQ2N+xsLjg== X-Received: by 2002:ad4:4ea9:0:b0:6b0:8f42:2435 with SMTP id 6a1803df08f44-6b2afd6a451mr138740856d6.51.1718609357156; Mon, 17 Jun 2024 00:29:17 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6214:4383:b0:6b0:8070:fdc5 with SMTP id 6a1803df08f44-6b2a8d3eee7ls63263356d6.2.-pod-prod-04-us; Mon, 17 Jun 2024 00:29:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWDwmpbZWsYlHc4ZUjrteL9yiX2Qkf+JOrQfwq4Tu1AGHKtjTHJ8JA4GEfBYlSbrgyhIptVXy8Yw2Td6/qOd4ScQnN/aOjR6u9F X-Received: by 2002:a05:6122:3196:b0:4df:235b:8ba1 with SMTP id 71dfb90a1353d-4ee3f261970mr8111388e0c.7.1718609355645; Mon, 17 Jun 2024 00:29:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718609355; cv=none; d=google.com; s=arc-20160816; b=BXWgZfZbGz9FkekACvHlbhDTgWA6OJGP/GM/P1tYoIXC8atee9pVT7EmHsqQJ6AU/x jRyB0codHvo10bK7cykCTgNlm9e69uO3nuDm1pohcpJwgeEwbI20Ka7dv5GFvUizaNBi K7De27xcD5/iPd0Vo0UYjChYZrkxT0dLEYVx/l06uOMrSG+P9hSP/70GI/oZCKwVoGG9 /E5eou1cer97kUA2a6Kj+U+R8yoziDWyEaadJeG+m7dU3tqT72c0tSmzEIJY/v8HUuyT BAnlGeH0mEVFOe1pZu856j89LNkqIiX4XeC7EB5hyt0rlbwozlIojEJ73fTm6g830a1n kYnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=C89MiWLQ+034LYhuSN405yqLRwKjaIj1t6B37p3x1/k=; fh=iqKm7PiuMmizbDEw9lCvRKpkySjdEn9ghL8di9hToes=; b=oOmfCN6yJb6AMcYCoCnG2rlq/t+a0ziLBbGbjD09PcssSmQqDST/0j364sFPSkDdvk TZt+6Yr2HHt+/alCBAwrGar0jLMysYovTB3QxYFDPTrwCw077UuwkOV3yxxi5VgaS+JT NOr5xJK/mFo98RzkX7sFmotzBxLHVFCT7m4lGgvL/VXIR5z4mqUdk8aP1Nc/xxoZT2xV g02BzZAYkrLF1HRAwPgxSJ2AEWgKJphAvvNHBqOvz05LGUffp4juupwQFcN+oBr4TfX9 BkRnRtCo84ZT6jFJdrW0RgAGCpX/FI3PfZgH8aE1ATipHHjHelaGLvP1/b3qdj0acgQD RbxQ==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b=lZnRAL8P; dkim=pass header.i=@atmark-techno.com header.s=google header.b=H5qHeNFb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=atmark-techno.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTPS id 71dfb90a1353d-4ed3c6a4bd0si569209e0c.0.2024.06.17.00.29.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 00:29:15 -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 5AB79148 for ; Mon, 17 Jun 2024 16:29:13 +0900 (JST) Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by gw2.atmark-techno.com (Postfix) with ESMTPS id 7965D4A7 for ; Mon, 17 Jun 2024 16:29:12 +0900 (JST) Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-649731dd35bso3480440a12.0 for ; Mon, 17 Jun 2024 00:29:12 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCWNRwqOQKtho2FoSWruI01x+LHOlq6AVz4eEs3NqjS5thAN3OEQPuP6NGSa6IT6vqogVlfe0trKQGdAMOeH3H5sgrPWMdeZlHkk X-Received: by 2002:a05:6a20:7f9e:b0:1b8:94a0:4a65 with SMTP id adf61e73a8af0-1bae8268dd3mr9346066637.36.1718609351515; Mon, 17 Jun 2024 00:29:11 -0700 (PDT) X-Received: by 2002:a05:6a20:7f9e:b0:1b8:94a0:4a65 with SMTP id adf61e73a8af0-1bae8268dd3mr9346058637.36.1718609351147; Mon, 17 Jun 2024 00:29:11 -0700 (PDT) Received: from pc-0182.atmarktech (35.112.198.104.bc.googleusercontent.com. [104.198.112.35]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f855e559fasm73748055ad.52.2024.06.17.00.29.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jun 2024 00:29:10 -0700 (PDT) Received: from [::1] (helo=pc-0182.atmark.tech) by pc-0182.atmarktech with esmtp (Exim 4.96) (envelope-from ) id 1sJ6nd-009Y52-1T; Mon, 17 Jun 2024 16:29:09 +0900 From: Dominique Martinet To: stefano.babic@swupdate.org, swupdate@googlegroups.com Cc: Dominique Martinet Subject: [swupdate] [PATCH 2/4] cpio_utils: fill_buffer: fix return value on EOF after short read Date: Mon, 17 Jun 2024 16:29:03 +0900 Message-Id: <20240617072905.2275940-3-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240617072905.2275940-1-dominique.martinet@atmark-techno.com> References: <20240617072905.2275940-1-dominique.martinet@atmark-techno.com> MIME-Version: 1.0 X-Original-Sender: dominique.martinet@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b=lZnRAL8P; dkim=pass header.i=@atmark-techno.com header.s=google header.b=H5qHeNFb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , fill_buffer would return 0 after having filled buffer/updated checksums if it reaches the end of file (returns 0) after another read. In practice, this never happens because the caller knows how much to read, and chunks are smaller than what had been previously written in the pipe so this is a theorical problem, but because the checksums are correctly updated until the end this would not be detected if it happens in practice (the end of the data would just not be fed to the handler), so this is best fixed. Signed-off-by: Dominique Martinet Acked-by: Stefano Babic --- core/cpio_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/cpio_utils.c b/core/cpio_utils.c index 00b15f030c74..6178fedca216 100644 --- a/core/cpio_utils.c +++ b/core/cpio_utils.c @@ -73,7 +73,7 @@ static int _fill_buffer(int fd, unsigned char *buf, unsigned int nbytes, unsigne return -EFAULT; } if (len == 0) { - return 0; + return count; } if (checksum) for (i = 0; i < len; i++) From patchwork Mon Jun 17 07:29:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1948524 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=Cmo6eHE/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2001:4860:4864:20::3c; helo=mail-oa1-x3c.google.com; envelope-from=swupdate+bncbcwivbv7sugrbs6lx6zqmgqehrvefhy@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-oa1-x3c.google.com (mail-oa1-x3c.google.com [IPv6:2001:4860:4864:20::3c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W2hNG60j3z20fF for ; Mon, 17 Jun 2024 17:29:34 +1000 (AEST) Received: by mail-oa1-x3c.google.com with SMTP id 586e51a60fabf-254dfc90aadsf5333852fac.1 for ; Mon, 17 Jun 2024 00:29:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718609356; cv=pass; d=google.com; s=arc-20160816; b=LkG+jDSTMqqq46QVdStLlQQmVwPiuXPf8RZHpga4pAHaLyC41UzB257rphkoM8mEiU KLs9kZsYmFlPJ6Ole4aOByaOk7dhTf1349GfumbFc4cKaIO97er89dUJ2ujhc74X+10e bzo8zDZDDG0LnJjyfT3RaaIQjIpI0Du0J89ZrQZblR2Riyb4ish31mWQGofcdKN7EHGJ HJmsfJzje//6HryutY4QjVd1nVKax2zLKpxkjBpp+JBjPAlpKzyPuCoVQQG2fdgsWnrW qrNI5UmH4Wph+YE8ocs1GxWarTGh4FEZWGLvqEEcjqK8mw8aEdIiOJ61kqZxeQEI54AW 13EA== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=Up1uTVwmgy8Q6RIC6VdyG01mKR1JfodRNQRX8owU+8Q=; fh=pzZm1JUlYDwHgK9SaIJnB9dOBfxP6Wuno8spH69BLuo=; b=roWFxnhQnBNYMt2tqDjRYwSD2S4PUSUqGVBQlTLR93/y0sjiUZARDUHNzWr66O4LF8 uAvvLWDzpm5RfL1ZZZS2B83gGcSmFOHujRNnKIhwdQz5eV9k8CC0kW4zJuUbpR49KbF1 882GybXVG7iL7OxXlDYmOSTmgbwjMnriYcN7HkP5Oou/fYx7OPmpd1Xi8L+rSNMZdPbT osEaR7GhYFcvyN9mVlJmhd6CDbtOBJlBQcnY4LqpsGQ3ZLKKJgesfo5eMxBpseezXt2u 3xd5mQg1PPplsAFir049q9ew0GE0XZIJ1HS3V31sbSEZMgW80AAE0/1dV76H45WGhGsw SvVQ==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b=C+LdnVP4; dkim=pass header.i=@atmark-techno.com header.s=google header.b=Q7bjZi8K; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=atmark-techno.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1718609356; x=1719214156; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:sender:from:to:cc:subject:date:message-id :reply-to; bh=Up1uTVwmgy8Q6RIC6VdyG01mKR1JfodRNQRX8owU+8Q=; b=Cmo6eHE/JKeUemqEvDlLwN+L/lJpHavtNjUW5IXf9PYzR9Mrj3zBQLwyw1t50XGp2L 2ey0uJ23K4B3SB06cHJAsIIr0cg7fsvBFx5IeEHTTpDAr1skjCpVscgV7QQFubhiVmV7 R3iyX+8c0tzqaaZyIdHIFbarJ0GVhBx3yB6+on7tSD/8VP0ZCrsfVyFv7WR98Cl6Hn1p C88MfzMuI/j1ea+HWHskkwejXwKRCn4yw2AdGF8F+eLRRhtETxoPZ/vGah7GDZIKTr9G HhD6vRXd4+esNT4D2My7T8MR9MiTv+vLxFRoUXueAe6AXCnUv51q5DBdthaRSa7UKwLF DCdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718609356; x=1719214156; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:sender:from:to:cc:subject:date :message-id:reply-to; bh=Up1uTVwmgy8Q6RIC6VdyG01mKR1JfodRNQRX8owU+8Q=; b=KSJyGECHz4ElSFzCzYJNyp6EOCbcgfmyqieSInW6oedpau4weEJ7tWXxWvSNQEXXXH jl3T6JPRUJiGznBsnnlaW8h5WS+Q3iGRZTge7vH8iC5dl1rFquROtnLqcmubfj0t1n9W WwxZQdPfzZ2hVwlFdN5yB3MIDZWFSd30rGyBjjpkqzjScf3tOvdiKxhzUQh9+RnF+mwr P9Nf/dVHZ5BJV1oGSgb491R/YveRLY5R3vOZv0ehnj8fwpdN1iG6VSbGXd2V1wM2OEJ4 e0R0+FJmeUIADxM6QH+53S4RVu2DOUrnnVnEC7fxPYgAbJgrt1U8qPfP/6a2Wk5lBQsz Rkdw== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCVa+HXGrdknG5nhZ4jRJ+JZq9nNPe/relemaP6fgN3EjP6ixHUrdD1AkGD+Jp1/KBxvZLqJfS6+uVgFCJDNR9UCZJjc6PdWDd+9IBEKew== X-Gm-Message-State: AOJu0Yxu1W6GEBJhMlWQ9xrAb72Y0JD4/WA6DbdK9xbTTWTfe/aJX78C wAXCTHZWkuhHfI8ZDP5sQI/lbIw2hOTGEOFQidAaK/4T4OxFHAFX X-Google-Smtp-Source: AGHT+IGbExUTUi2kr+bAtYHVOezVB3Jla7yvPPyi1TUB3ZJ1tkJAgcD8k/O4R939Bw2VhCCbSUTYMw== X-Received: by 2002:a05:6870:1687:b0:254:a8ec:306e with SMTP id 586e51a60fabf-2584288e481mr11362531fac.7.1718609355847; Mon, 17 Jun 2024 00:29:15 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6870:c6a3:b0:24f:fada:1780 with SMTP id 586e51a60fabf-2552bbe8b5els2759425fac.1.-pod-prod-08-us; Mon, 17 Jun 2024 00:29:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXbTH8LE5D+XnLS5ll/BWMUqnGCvWIZQWWvzC7aF0a14+nuFvImFZhSsi/VlPlZHw54gLXStW7vzL0VE+kSBWhTdC1uYHpwzgBt X-Received: by 2002:a05:6870:14cf:b0:254:92a5:fa44 with SMTP id 586e51a60fabf-2584288e45emr10814803fac.10.1718609354598; Mon, 17 Jun 2024 00:29:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718609354; cv=none; d=google.com; s=arc-20160816; b=PBP3F4UnATgdJkfzB+IJXK31FCLpHNN8BKo7k42XyLowtmyitZkgZqisXCfhpHyyEa d8vGfCQhoonB230usggIEY/aBQ/P8JhpWEP9sTc0Pbq+GGLf5D3oYVfdcQUINekP6CCn AsNO7FoUdIdRDKd7RhNcTlFM3pr0H6DxtaGmlGN2QlMopN8rGVpMLQGmou4mgvPq/n5b PkB78gcaRyLrYi+QKvZIZcif1yHjRbxvHM7SzMSnpXjIkkq16Cn3vee7a3vBbueFraBt cFaI56jgrHhXrGvedM6RJ2hOdDQh9dd+42Ul0apXlMtDrYogmGTTXivKw1fFgesJHjfq l8sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=6cAglcd5Fda5QMHtnwgL/R6GMQPZXqiZScKCrA3wqks=; fh=qJTfuJd+VnhouonnIWk6WYt6Rb3rKS4zF7uMnLyxXTk=; b=NWn8cU+vnP60d53CuMEDEk4AGzA0O4BiRTZ/XRgwNqKMPQh6ShNBOKWnFuH54D2NIC vVOaEnFKDQ+8no2wa4JJ8fsXJY3iX1uVGBwDGsTPi0dtdWtFfZmygQhWEJfILNZbvy+4 jQqZQ6dGnVCBy33CrSCjVlJKoeQvLd6aWVSrockPBszvjYa/8Zk/5dOpQ9i3AR5BUPmv HuW9I/oKcBE18CkN7uVRYDv2axnw6bWAcC+eAjXAEywXrbc/E7qUIfXembHHzvDZLKCF 0NOlWl4prcT4KO3XJSF8xCJS3ryVgZW1b5K2vEe/bqEvMK0CPoIbNmP75lFDTK7Rqsnr uVwg==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b=C+LdnVP4; dkim=pass header.i=@atmark-techno.com header.s=google header.b=Q7bjZi8K; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=atmark-techno.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTPS id d2e1a72fcca58-705cc775575si338909b3a.0.2024.06.17.00.29.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 00:29:14 -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 E642796A for ; Mon, 17 Jun 2024 16:29:12 +0900 (JST) Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by gw2.atmark-techno.com (Postfix) with ESMTPS id 441C54AB for ; Mon, 17 Jun 2024 16:29:12 +0900 (JST) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-1f736a80b97so35410715ad.0 for ; Mon, 17 Jun 2024 00:29:12 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCW8rM14PPNpdJ/ghC5lgIaLj9rnzoAa4VYLW6q1BU1yWBncBFbgAwDqM/FajkuzDYkxPyn2wnXPUf5IH46DNstptBF4EItdcHaW X-Received: by 2002:a17:902:cec6:b0:1f7:36a8:671d with SMTP id d9443c01a7336-1f8625cf720mr124935345ad.25.1718609351162; Mon, 17 Jun 2024 00:29:11 -0700 (PDT) X-Received: by 2002:a17:902:cec6:b0:1f7:36a8:671d with SMTP id d9443c01a7336-1f8625cf720mr124935205ad.25.1718609350788; Mon, 17 Jun 2024 00:29:10 -0700 (PDT) Received: from pc-0182.atmarktech (76.125.194.35.bc.googleusercontent.com. [35.194.125.76]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f855e55c8bsm74065695ad.48.2024.06.17.00.29.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jun 2024 00:29:10 -0700 (PDT) Received: from [::1] (helo=pc-0182.atmark.tech) by pc-0182.atmarktech with esmtp (Exim 4.96) (envelope-from ) id 1sJ6nd-009Y52-1f; Mon, 17 Jun 2024 16:29:09 +0900 From: Dominique Martinet To: stefano.babic@swupdate.org, swupdate@googlegroups.com Cc: Dominique Martinet Subject: [swupdate] [PATCH 3/4] copyfile cleanup: use copyimage when we can Date: Mon, 17 Jun 2024 16:29:04 +0900 Message-Id: <20240617072905.2275940-4-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240617072905.2275940-1-dominique.martinet@atmark-techno.com> References: <20240617072905.2275940-1-dominique.martinet@atmark-techno.com> MIME-Version: 1.0 X-Original-Sender: dominique.martinet@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b=C+LdnVP4; dkim=pass header.i=@atmark-techno.com header.s=google header.b=Q7bjZi8K; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , There were a few handlers manually passing all the fields required for copyimage, use copyimage instead. lua was using img.checksum as a secondary hash, preserve this functionality by remembering the old img.checksum instead of passing a different checksum pointer. There is no intended functional change. Signed-off-by: Dominique Martinet Reviewed-by: Michael Glembotzki Reviewed-by: Stefano Babic --- corelib/lua_interface.c | 38 ++++++++------------------------------ handlers/delta_handler.c | 13 +------------ handlers/rdiff_handler.c | 13 +------------ 3 files changed, 10 insertions(+), 54 deletions(-) diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index 03b74aed1cf2..10af0760c5f9 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -388,7 +388,7 @@ static int l_copy2file(lua_State *L) } struct img_type img = {}; - uint32_t checksum = 0; + uint32_t image_checksum = img.checksum; table2image(L, &img); if (check_same_file(img.fdin, fdout)) { @@ -397,18 +397,7 @@ static int l_copy2file(lua_State *L) lua_pushstring(L, "Output file path is same as input file temporary path"); goto copyfile_exit; } - int ret = copyfile(img.fdin, - &fdout, - img.size, - (unsigned long *)&img.offset, - img.seek, - 0, /* no skip */ - img.compressed, - &checksum, - img.sha256, - img.is_encrypted, - img.ivt_ascii, - NULL); + int ret = copyimage(&fdout, &img, NULL /* default write callback */); update_table(L, &img); lua_pop(L, 1); @@ -417,10 +406,10 @@ static int l_copy2file(lua_State *L) lua_pushstring(L, strerror(errno)); goto copyfile_exit; } - if ((img.checksum != 0) && (checksum != img.checksum)) { + if ((image_checksum != 0) && (image_checksum != img.checksum)) { lua_pushinteger(L, -1); lua_pushfstring(L, "Checksums WRONG! Computed 0x%d, should be 0x%d\n", - checksum, img.checksum); + img.checksum, image_checksum); goto copyfile_exit; } @@ -463,24 +452,13 @@ static int l_istream_read(lua_State* L) luaL_checktype(L, 2, LUA_TFUNCTION); struct img_type img = {}; - uint32_t checksum = 0; + uint32_t image_checksum = img.checksum; lua_pushvalue(L, 1); table2image(L, &img); lua_pop(L, 1); - int ret = copyfile(img.fdin, - L, - img.size, - (unsigned long *)&img.offset, - img.seek, - 0, /* no skip */ - img.compressed, - &checksum, - img.sha256, - img.is_encrypted, - img.ivt_ascii, - istream_read_callback); + int ret = copyimage(L, &img, istream_read_callback); lua_pop(L, 1); update_table(L, &img); @@ -491,10 +469,10 @@ static int l_istream_read(lua_State* L) lua_pushstring(L, strerror(errno)); return 2; } - if ((img.checksum != 0) && (checksum != img.checksum)) { + if ((image_checksum != 0) && (image_checksum != img.checksum)) { lua_pushinteger(L, -1); lua_pushfstring(L, "Checksums WRONG! Computed 0x%d, should be 0x%d\n", - checksum, img.checksum); + img.checksum, image_checksum); return 2; } lua_pushinteger(L, 0); diff --git a/handlers/delta_handler.c b/handlers/delta_handler.c index 8e7faa0ead02..5ec243ee01d9 100644 --- a/handlers/delta_handler.c +++ b/handlers/delta_handler.c @@ -999,18 +999,7 @@ static int install_delta(struct img_type *img, goto cleanup; } - ret = copyfile(img->fdin, - &mem_fd, - img->size, - (unsigned long *)&img->offset, - img->seek, - 0, - img->compressed, - &img->checksum, - img->sha256, - img->is_encrypted, - img->ivt_ascii, - NULL); + ret = copyimage(&mem_fd, img, NULL /* default write callback */); if (ret != 0) { ERROR("Error %d copying zchunk header, aborting.", ret); diff --git a/handlers/rdiff_handler.c b/handlers/rdiff_handler.c index e01a127bce50..3b01519ce80a 100644 --- a/handlers/rdiff_handler.c +++ b/handlers/rdiff_handler.c @@ -337,18 +337,7 @@ static int apply_rdiff_patch(struct img_type *img, rs_trace_to(rdiff_log); rdiff_state.job = rs_patch_begin(base_file_read_cb, rdiff_state.base_file); - ret = copyfile(img->fdin, - &rdiff_state, - img->size, - (unsigned long *)&img->offset, - img->seek, - 0, /* no skip */ - img->compressed, - &img->checksum, - img->sha256, - img->is_encrypted, - img->ivt_ascii, - apply_rdiff_chunk_cb); + ret = copyimage(&rdiff_state, img, apply_rdiff_chunk_cb); if (ret != 0) { ERROR("Error %d running rdiff job, aborting.", ret); goto cleanup; From patchwork Mon Jun 17 07:29:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 1948521 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=Isis2Ryg; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::103b; helo=mail-pj1-x103b.google.com; envelope-from=swupdate+bncbcwivbv7sugrbtolx6zqmgqejmmi5ty@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-pj1-x103b.google.com (mail-pj1-x103b.google.com [IPv6:2607:f8b0:4864:20::103b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W2hNC6yXzz20XJ for ; Mon, 17 Jun 2024 17:29:29 +1000 (AEST) Received: by mail-pj1-x103b.google.com with SMTP id 98e67ed59e1d1-2c2dfb3d3e2sf4502704a91.1 for ; Mon, 17 Jun 2024 00:29:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718609358; cv=pass; d=google.com; s=arc-20160816; b=uMxNZvr9q5Mc8bJrbKt9ygMiW9BPH5hWrmx8CvIzkznGU/IIJoD4xc0zXnC3tBvUb5 2fn1B63PhclcQ6dOILG/uSmT4MwcO8DLU7qeI1EbqYBZ3OE8y75lCzTHLeLDdhXyMLqy 9/tqusgyj3MHaf6Zt5WA6Bg6DrdeJjUqbkZr1HNDGoYKVRsRLFgim2jUcxeYtYe+blCh YzYsSgdnuIVDYxBbITnvjvLUkM8G8eWt+cgv3bxEXkTf/+FP5pGLLU0c7KlacomajzB+ H4QA9C/xyl9+nMpnUMQ4EFnmxsEyTTng5dU1qdT9C6sdCr0Cn1EoOGSoqgdpWjeZr9jP qSwA== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=1uOPacDNsmHC2FemyWucglX1LgBdJ6B4MudtgK5tfks=; fh=KckhmgOTzMXd+oQ1YyXRSlE1Lu3ww+xG+HlLmw1rEXM=; b=ZuSrOI8bJK9ffQiVQw/uamtqegatqKd1Cf8uTPegm2a+9JcvVbRLmBq3zzZ4e90ZJU v6hbOUNUEoGaBKsYzE0djJAtb5pDxLqN77qY1eeDx1hOg/W1v6RQhi19bFWMY8fMhUU3 p2wq+jqTXPp0y32HhUkqGZP0O3lLABnZTLh137OY57Ku+ZFmQ9NwaTsRCC3AR3xLsY6m bwr1468dqdJxMkGciSo/bun+SIpPYV+7VLEnXZ7yI3iDgaE8w+xuyldj2YmovvlNO4SJ v791lVClqqjmBbutv3kUAjwOWQtMx9El0nj6z60iQIqTmaCFvSH4wmZAt7mwnaQD65pD lPWw==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b=uOtbD9EY; dkim=pass header.i=@atmark-techno.com header.s=google header.b=L4nGGdYH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=atmark-techno.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1718609358; x=1719214158; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:sender:from:to:cc:subject:date:message-id :reply-to; bh=1uOPacDNsmHC2FemyWucglX1LgBdJ6B4MudtgK5tfks=; b=Isis2Ryg/PbVh98G/j9eta5d7kxPXbhLfv+8YFRVqF28iTRsZ9tm6vM1j/iXdjFdNS 93RWYpKiuVZs7oqECP24+3ezekGh/9dma06S02yF+HbEpGquyQDbqidqjUoEz+Q8nSxz RHtLrXRhU5zV7ScPTcYfD4xjeOKQN1pl+1tr5aQKb26nWMxO6p6a2BpJltmxxfuFIs/U Rj+nLCFf8zFIZJR985anlPTqbrGMsUKi77pXVIhK9+u2X5hgmomDO7t6VCeGA8ZPM+EO bQ5ilO2QI3EuOT1fL+ZWPwYA2VW6mnSYqjLAcuOG5kqeRTIoQIl4nwV8pQ/mxQLXZn+v Yc3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718609358; x=1719214158; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:sender:from:to:cc:subject:date :message-id:reply-to; bh=1uOPacDNsmHC2FemyWucglX1LgBdJ6B4MudtgK5tfks=; b=V8sef1h/WQYm0uGvd08Fki3PvE9TanhZqxe2X3wsB/Xd5fXQO7mqQn8Ziufg2H3i1d +ziF/t7X/OHA5Ygc1JIBZGla7HIO8gXmIwgS7+PNnGTNeQOgvW2dng110QqD8aG/yflg Oj4HuDP3zbsbV737SxscDKK80crTx/GMK3P3IGLXLxkkIn6nBAjauZL5xv/ZFmIsfGoZ JlQTZpDQlCqWcLiClKeSEWq0zsx6mz+HhSOhQY1urMQCwDVZFfQGB/cKusOFZbjbOIof kNtbILRW2rLJRn4isdEuwrG7WxUKY6nlvns8hYs6tSmGf5dqvlZgWEjoMFr2pgULSlTT SASA== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCWApDkeM+SOWxlOlcSxycTJxZwpBshg6Y1m63GZ5PI2JOVr69nbaA3ybH2EOaSVYX27lQuzmspWo06K4QhVngOQZ23Z28f52kgRCSMdew== X-Gm-Message-State: AOJu0Ywmssm87CmYXqBwgywAqMX7q1lDfTXT1sTubHtqhZZa1Ht83RsW pMdmSrpnVAMd3C6Nq7TeliYhl5aN8Pw5Ryb+zJE1d83VkbxihEse X-Google-Smtp-Source: AGHT+IHDTCyI8JIZpqPGbyndChTCkE89Epj0Ee06Y4bqAN2/3BUZs6V9wIwD8x/mkUC1cZ/UT3UiHg== X-Received: by 2002:a17:90b:3552:b0:2c4:e62c:b506 with SMTP id 98e67ed59e1d1-2c4e62cb63dmr7145085a91.27.1718609357913; Mon, 17 Jun 2024 00:29:17 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:90a:520d:b0:2c3:1e98:ecbc with SMTP id 98e67ed59e1d1-2c4bde91b67ls2061110a91.1.-pod-prod-08-us; Mon, 17 Jun 2024 00:29:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWtWl0ymmj7skxNfg94vdUFk2pakCbdJCAtQO0xYgYkIW/rO8YVhLIoGzyxqjucYi5OtVAfr42shz6ENNG38+7NIxiKtu2inlXq X-Received: by 2002:a17:90a:608:b0:2c2:dfc3:10b6 with SMTP id 98e67ed59e1d1-2c4db44b84emr8638335a91.24.1718609356215; Mon, 17 Jun 2024 00:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718609356; cv=none; d=google.com; s=arc-20160816; b=lqhv/VOirLPY/e14KFg+MidTQdi18X2KpoQbfBvs96m3oSdSRcrVY0UFH71v72u9xk 4iT3XSwP1Kl2gJ6WtuVzIDxHvPADnQ+jw0BMDiPrhgFmCrvnEkO9Q+bZTA/2OJxOgxG3 wFj16C9MRGefY8Yqjhs9qSAh0bruTiE3QyVJ6VD26QbyUSlCkRgmMkbYSvDNj0k8fYhs 53FXdAL9mFTLuEvnERlaGxKnDyDjYQemN+wethyXRgXyqlQsSBb2JFJUQfA8j1igrXG1 rgUDB0welsEtpcCxtwc/40UaKhrEbIuAJA80csXAMccr/Oe1nzIh4Ifq5sCeq0i2kgkI 5Txg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=9KsT9YCfCrOEgDFjw5Tk+8EKQtnys1EdKkkmmPAO/ww=; fh=xUi0OOZu4pwpxqlTod0MW3ruynZ5mxaDdmmXpKJFw+Q=; b=ytGN4YLUDhK0gv1bG8GrKybDDvm5Mum81sUN3lyJGRE5k9Izy4dN67pUvL9K/p85CS s0S+jenwCa9TLlhGxTUxNUI+G8b5aWXSROOTDHmbnSAHBnQB7ag6PvjEA+q1Mb7J7BTW 0yNtyMXobKNE+6vLl442070LDBIERLL9ZhmtBNJy+W4FDKLkYD6TTssLJ4FLuTyvorZL 5kzq9/AXWM9vobIEDemf2fR/jfiOsOMTs+f14HCdxtCKmTJW506NsrbUUukuZZAcEXUa tTaZpfVO/xz5MPGC+0ywwsA9Ejpg61VnLT8W6i+T6koRMS9yypKuM2RvgEqIB2EwdLPI zLAg==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b=uOtbD9EY; dkim=pass header.i=@atmark-techno.com header.s=google header.b=L4nGGdYH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=atmark-techno.com Received: from gw2.atmark-techno.com (gw2.atmark-techno.com. [35.74.137.57]) by gmr-mx.google.com with ESMTPS id 98e67ed59e1d1-2c50f04cfcdsi187471a91.0.2024.06.17.00.29.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 00:29:16 -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 85C20A80 for ; Mon, 17 Jun 2024 16:29:14 +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 CCF97A85 for ; Mon, 17 Jun 2024 16:29:13 +0900 (JST) Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-705bbf10f90so4232368b3a.1 for ; Mon, 17 Jun 2024 00:29:13 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCV6n+6HZfZGFysR6h/EOqXnDv6fW0exEvMyRxCAM5p4Mq7nTUvHwokz6VgRJUDJR5l5nHwgZpVhLJ62QbqXJe71y8FwMJ9VZxV+ X-Received: by 2002:a05:6a00:51:b0:6ed:21c0:986c with SMTP id d2e1a72fcca58-705d71bd5c2mr11149285b3a.24.1718609352566; Mon, 17 Jun 2024 00:29:12 -0700 (PDT) X-Received: by 2002:a05:6a00:51:b0:6ed:21c0:986c with SMTP id d2e1a72fcca58-705d71bd5c2mr11149276b3a.24.1718609352193; Mon, 17 Jun 2024 00:29:12 -0700 (PDT) Received: from pc-0182.atmarktech (117.209.187.35.bc.googleusercontent.com. [35.187.209.117]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705cc91e13esm7093321b3a.11.2024.06.17.00.29.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jun 2024 00:29:11 -0700 (PDT) Received: from [::1] (helo=pc-0182.atmark.tech) by pc-0182.atmarktech with esmtp (Exim 4.96) (envelope-from ) id 1sJ6nd-009Y52-1r; Mon, 17 Jun 2024 16:29:09 +0900 From: Dominique Martinet To: stefano.babic@swupdate.org, swupdate@googlegroups.com Cc: Dominique Martinet Subject: [swupdate] [PATCH 4/4] cpio_utils: cleanup state chaining code Date: Mon, 17 Jun 2024 16:29:05 +0900 Message-Id: <20240617072905.2275940-5-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240617072905.2275940-1-dominique.martinet@atmark-techno.com> References: <20240617072905.2275940-1-dominique.martinet@atmark-techno.com> MIME-Version: 1.0 X-Original-Sender: dominique.martinet@atmark-techno.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@atmark-techno.com header.s=gw2_bookworm header.b=uOtbD9EY; dkim=pass header.i=@atmark-techno.com header.s=google header.b=L4nGGdYH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , We don't need to nest ifs so much, chain steps as they become required. The step order (input step, decryption, decompression) is preserved. There is no intended functional change. Signed-off-by: Dominique Martinet Reviewed-by: Michael Glembotzki --- core/cpio_utils.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/core/cpio_utils.c b/core/cpio_utils.c index 6178fedca216..65f301909f0c 100644 --- a/core/cpio_utils.c +++ b/core/cpio_utils.c @@ -590,31 +590,22 @@ static int __swupdate_copy(int fdin, unsigned char *inbuf, void *out, size_t nby } } + step = &input_step; + state = &input_state; + + if (encrypted) { + decrypt_state.upstream_step = step; + decrypt_state.upstream_state = state; + step = &decrypt_step; + state = &decrypt_state; + } + #if defined(CONFIG_GUNZIP) || defined(CONFIG_ZSTD) if (compressed) { - if (encrypted) { - decrypt_state.upstream_step = &input_step; - decrypt_state.upstream_state = &input_state; - decompress_state.upstream_step = &decrypt_step; - decompress_state.upstream_state = &decrypt_state; - } else { - decompress_state.upstream_step = &input_step; - decompress_state.upstream_state = &input_state; - } + decompress_state.upstream_step = step; + decompress_state.upstream_state = state; step = decompress_step; state = &decompress_state; - } else { -#endif - if (encrypted) { - decrypt_state.upstream_step = &input_step; - decrypt_state.upstream_state = &input_state; - step = &decrypt_step; - state = &decrypt_state; - } else { - step = &input_step; - state = &input_state; - } -#if defined(CONFIG_GUNZIP) || defined(CONFIG_ZSTD) } #endif