From patchwork Tue Apr 30 12:43:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Glembotzki X-Patchwork-Id: 1929493 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=kwjayMC8; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=EOe9prcn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::139; helo=mail-lf1-x139.google.com; envelope-from=swupdate+bncbdy5juxlviebbh6pyoyqmgqei35jmia@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lf1-x139.google.com (mail-lf1-x139.google.com [IPv6:2a00:1450:4864:20::139]) (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 4VTKdc5XbRz20fY for ; Tue, 30 Apr 2024 22:44:19 +1000 (AEST) Received: by mail-lf1-x139.google.com with SMTP id 2adb3069b0e04-516c8697daasf4373588e87.2 for ; Tue, 30 Apr 2024 05:44:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714481056; cv=pass; d=google.com; s=arc-20160816; b=re+E8kl+35KbGP8QKCRjVFDNYwS1iwQKNfx7awYITt5gVptKRPpn3tpVNtWRPOoSE9 N4PPlwLnfQ7Rhbpiqy78P3y0mZfioxPSgXAzX/s/gMKKwR+FulNJ53oDZ011fIgKldns mXJVR4d9G5J+j0l2LWFWYOSdLxzBb2S5sdDueTgPbIDYVFvyki9aLyr0c87dH+Cub19V /5RgpI3PD+OhaCjigOVj14sqPp3jMw4NkomuxxmxzRTSrXpSVE9sAQTL/Dd39RL39HFQ M7gSs92xNcJt6ZKlY0YjTlnq6I6AJ/WGABX9YzAq7LLAHaOOsRtWU98F00ZzoxklTA1n zrvw== 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:dkim-signature; bh=Lp+QRj9U/mOCQ+A5vvOiOSUG5g1nRdL5Dn431V2eqNw=; fh=6sbPPd7UgEDhblDxbKOXFlwloa+KBGFcz3+7At78oRc=; b=Xa/2I6c6/dc084XtiiIks7Do3L6/uFihGJ/bEpvoWdBiQc0CX3lZsPsU6cq9ho9LZW N3UeM+osS9n63ok1IxLWVywEMkHvdn/LNiD0LfWwZaQ+kiRP6akX6cR3Riu0bi9pKKeS B1H8b9mZvBpzkZlidEuxB6MrTJUOX5sdw1/lG3FGtYNQH26W+U6zEBrjUxvyTsSso7yL vVkwqMoN7pLLwFF45NUYLZdvpEskvl/FpprRvMv9TcoKtx8OmoFRF+wugViDDM+Ii8Z0 B3EpxFAQDHqYJA5hmBHAUaeluax8nm48h/8yu527ED34JiWsNquufjjubRyFOpuEQaWy dviA==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Z8kXlxuc; spf=pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::12c as permitted sender) smtp.mailfrom=m.glembo@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1714481056; x=1715085856; 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:message-id:date:subject:cc:to:from :sender:from:to:cc:subject:date:message-id:reply-to; bh=Lp+QRj9U/mOCQ+A5vvOiOSUG5g1nRdL5Dn431V2eqNw=; b=kwjayMC8Xu+Zo+6a0hu89zSJVe5IbGiUrsZG0SEMBgRgvjST2pzQ6U20V4fos6rbO3 o4Szi1g9B8EOkNiQx2TX+DjFuJjV9oftMcpMmLc0yy84JDeYzWmcsGNmt/JdwINhv6Ux y+jvTSDkkPoouWnBJMjMk28JD9HBlckrAyzZU+XzPuemAfYtfgW4FfmkxL6wWSNCz8ny L/9MnMg18hp6XI6Aot+lIevZnwee1had7NEs/8t6bA0TDlCWkAAmsb6GSGrqc+tYYC+p sZ4v6b0aoH3mBJ6xGuxiHLduAl3Wb25qtO0SKh9gz1Mc/WwhC/0PlgmYhigRayEZRrxx kylg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714481056; x=1715085856; 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:message-id:date:subject:cc:to:from :from:to:cc:subject:date:message-id:reply-to; bh=Lp+QRj9U/mOCQ+A5vvOiOSUG5g1nRdL5Dn431V2eqNw=; b=EOe9prcnCncxL8t9hn1NGb7jEd0Z+e2fnKhDzdQVBo1coJ1N8u4OrH0pL+8FuDweA6 Ctpag56XTBt6HRHPC/PvL590xINC3uv9i9O9DYlDvGMgcajtAZvVNBp4HpXqCKiivfCa CQSEd6jS4VCWkuqfLJQHxjAVMyHhDrHnITeKZYE/CStiUju6++Bh7amN3OUvjY4Wqgmk 30O4EtjEVH+A329KXnvQxhR4B9rSIX/HihhB7PJANgzvTpwW1MDMWHy22ZrfX49s1NXD wCN8pfwT8VImIogjHQRejNT3QTSAUqTxTdGx0LjoHz5e4G5xu3rn8v+Ecysb7WTWVS98 hUPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714481056; x=1715085856; 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 :message-id:date:subject:cc:to:from:x-beenthere:x-gm-message-state :sender:from:to:cc:subject:date:message-id:reply-to; bh=Lp+QRj9U/mOCQ+A5vvOiOSUG5g1nRdL5Dn431V2eqNw=; b=oWHZHYENolZv5yKRXiWd0diZOWVyGXsPU2lF4tPpg9uAxwAWU3GuaiENYKAii4Gv1e k1ssqlwd1hiCzjT0UP3fWscPpvTfe4I/76ccU6Jc+78qctVKEGyqaxR4pJI7SQ+HtkgI gxBilyurHT66FAQuAkSPFJTl2HfpuFO/bIPK5FwcKco9PNriEuTgmb82dHerUDPX1+br K6eQmKStKc0And3WGmWfen3yDxquJBWXmg/MPsy4mTeQ1qG1Na/QKdzzhcqzgqfJImnn xnbzGgkLpXAR/fpFM26NaFvIY02CQSL5XjwnaSLxPdMnlWAhED055Saieh4u+q4wT5H1 Rbeg== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCUIqpChDfk5gOcb1c+2Uh0GYe75tR8j7lJmheZzV0F/pwBqxEp3/XWJsIceQDXPvy9oMB6FlrfjmDhnpyK2e0LY9u7BD/mw6Q37eUTXuQ== X-Gm-Message-State: AOJu0Yw8Mt+NGa9H/UF3JMcEP0qW+RT4vitm99vz8uYJkza8bgwYjGCj qKY8y0yFWw/UsCnI/aco1ZVAAhrjx3G9pQqKefkqmSLQ4jJqW+gv X-Google-Smtp-Source: AGHT+IHWhMClJDjpY4mjspobqaJ09P2KMyd/GFMaUq0W2y0SYw5BbaNbYJr0W03j+5j5ASCFaO1pOg== X-Received: by 2002:a05:6512:5c6:b0:515:beef:837f with SMTP id o6-20020a05651205c600b00515beef837fmr1810978lfo.29.1714481056072; Tue, 30 Apr 2024 05:44:16 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:3ba0:b0:518:d08c:a411 with SMTP id 2adb3069b0e04-51c2fd03364ls788263e87.2.-pod-prod-03-eu; Tue, 30 Apr 2024 05:44:13 -0700 (PDT) X-Received: by 2002:a05:6512:3048:b0:51c:2070:c69d with SMTP id b8-20020a056512304800b0051c2070c69dmr2011611lfb.55.1714481053111; Tue, 30 Apr 2024 05:44:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714481053; cv=none; d=google.com; s=arc-20160816; b=X1dS6kxHxulVmB0LNzfuEJ25kUd9N7ebZaUn4nymo2INa86f7iIuU6p7kFX/81uzug ojLVD9IUUH6MR+c6YsyT6sTv/U4AmmxVdrtUYM14/fEhhV4Rs2DxIEsHnAdj5o6dPX/Q 4KsPmjAOWbNHV5UJ6adoV+cgwZODq5/i6lIvH3Mnm+cnxyHJ4/fOtrxfaE7OqRhFNor9 TJsn+SupqTdYenzNPEwc3zRlM2s1mHz1EtYUahkTk4RnfFRKU5sZ+O61AdMuQSoCwDLF hEMPLp5TMSEfcabqlAvS0ptrSU2uRZuODjrlBmE9cEiuZs185HIO5ol00Kb/RtHPAfuk 9pSA== 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:dkim-signature; bh=9yjQBErl2ZhDxw0InSSuYbUb/GZBQeilgQCg8iGk4/k=; fh=zydHuzCQWrku2OPQyZfraJZFcOpEXLQ/YBcu3QNiBd0=; b=vVGkvU6oFj58difpRw7ssn3mArCE9w4lXOu6kDjfgDzwECDPfKSho6prBYNWEDghuf IE/3gE7TPWsQzNKdGR158Ahpo+bVJgpnZ7YRioV5ahmcHHoIvH+gxVMNVav+HZpwNnsY eSliyvIc3zRKf2rqcff2LjTRzbepUypKMYxCRu6hz9ifxmKDousFqfNw1fG+nZwl5Rw5 HVw0tvz8CCD5tf4BHAX4IaLqCtmMOoraD+z5VpPRPmaf/rfc3Vj9eg984KrEsM3Ar5t1 02Vw5vmWda9qf//g+noxgJGj7zqaxJ7KYupPlAylGzCO3Y7WvvAzsTCa6TtNNaF9OW0d kcGw==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Z8kXlxuc; spf=pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::12c as permitted sender) smtp.mailfrom=m.glembo@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com. [2a00:1450:4864:20::12c]) by gmr-mx.google.com with ESMTPS id f13-20020a05651232cd00b0051d25e76034si103036lfg.3.2024.04.30.05.44.13 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Apr 2024 05:44:13 -0700 (PDT) Received-SPF: pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::12c as permitted sender) client-ip=2a00:1450:4864:20::12c; Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-516d1ecaf25so7825383e87.2 for ; Tue, 30 Apr 2024 05:44:13 -0700 (PDT) X-Received: by 2002:a05:6512:3d21:b0:516:9f1a:929d with SMTP id d33-20020a0565123d2100b005169f1a929dmr2432297lfv.1.1714481051752; Tue, 30 Apr 2024 05:44:11 -0700 (PDT) Received: from localhost.localdomain ([2a02:8108:96c0:76fc::3f69]) by smtp.gmail.com with ESMTPSA id a101-20020a509eee000000b00572459a4ffesm5869281edf.56.2024.04.30.05.44.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 05:44:11 -0700 (PDT) From: Michael Glembotzki To: swupdate@googlegroups.com Cc: Michael Glembotzki Subject: [swupdate] [PATCH 1/3] stream_interface: Fix 16kB issue on save_stream Date: Tue, 30 Apr 2024 14:43:14 +0200 Message-ID: <20240430124316.1714467-1-Michael.Glembotzki@iris-sensing.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Original-Sender: m.glembo@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Z8kXlxuc; spf=pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::12c as permitted sender) smtp.mailfrom=m.glembo@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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: , The first two cpio blocks are alternately read into tmpfd. Previously it was assumed that both files fit into a 16 kB buffer. Signed-off-by: Michael Glembotzki Reviewed-by: Stefano Babic --- core/stream_interface.c | 72 +++++++++++++++++++++++------------------ include/util.h | 1 - 2 files changed, 41 insertions(+), 32 deletions(-) diff --git a/core/stream_interface.c b/core/stream_interface.c index 5ebaca68..5f3ad2e3 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -374,7 +374,6 @@ static int save_stream(int fdin, struct swupdate_cfg *software) { unsigned char *buf; int fdout = -1, ret, len; - const int bufsize = 16 * 1024; int tmpfd = -1; char tmpfilename[MAX_IMAGE_FNAME]; struct filehdr fdh; @@ -383,7 +382,11 @@ static int save_stream(int fdin, struct swupdate_cfg *software) char output_file[MAX_IMAGE_FNAME]; const char* TMPDIR = get_tmpdir(); bool encrypted_sw_desc = false; + int files = 1; +#ifdef CONFIG_SIGNED_IMAGES + files = 2; // sw-description and sw-description.sig +#endif #ifdef CONFIG_ENCRYPTED_SW_DESCRIPTION encrypted_sw_desc = true; #endif @@ -392,7 +395,7 @@ static int save_stream(int fdin, struct swupdate_cfg *software) snprintf(tmpfilename, sizeof(tmpfilename), "%s/%s", TMPDIR, SW_TMP_OUTPUT); - buf = (unsigned char *)malloc(bufsize); + buf = (unsigned char *)malloc(sizeof(struct new_ascii_header)); if (!buf) { ERROR("OOM when saving stream"); return -ENOMEM; @@ -410,39 +413,46 @@ static int save_stream(int fdin, struct swupdate_cfg *software) ret = -EFAULT; goto no_copy_output; } - len = read(fdin, buf, bufsize); - if (len < 0) { - ERROR("Reading from file failed, error %d", errno); - ret = -EFAULT; - goto no_copy_output; - } - if (get_cpiohdr(buf, &fdh) < 0) { - ERROR("CPIO Header corrupted, cannot be parsed"); - ret = -EINVAL; - goto no_copy_output; - } /* - * Make an estimation for sw-description and signature. - * Signature cannot be very big - if it is, it is an attack. - * So let a buffer just for the signature - tmpsize is enough for both - * sw-description and sw-description.sig, if any. + * Copy first two cpio blocks (sw-description and sw-description.sig) into tmpfd */ - tmpsize = SWUPDATE_ALIGN(fdh.size + fdh.namesize + sizeof(struct new_ascii_header) + bufsize - len, - bufsize); - ret = copy_write(&tmpfd, buf, len); /* copy the first buffer */ - if (ret < 0) { - ret = -EIO; - goto no_copy_output; - } + while (files-- > 0) { + len = fill_buffer(fdin, buf, sizeof(struct new_ascii_header)); + if (len < 0) { + ERROR("Reading from file failed, error %d", errno); + ret = -EFAULT; + goto no_copy_output; + } - /* - * copy enough bytes to have sw-description and sw-description.sig - */ - ret = cpfiles(fdin, tmpfd, tmpsize); - if (ret < 0) { - ret = -EIO; - goto no_copy_output; + if (get_cpiohdr(buf, &fdh) < 0) { + ERROR("CPIO Header corrupted, cannot be parsed"); + ret = -EINVAL; + goto no_copy_output; + } + + ret = copy_write(&tmpfd, buf, len); + if (ret < 0) { + ret = -EIO; + goto no_copy_output; + } + + /* + * calc remaining bytes of the cpio block + */ + tmpsize = sizeof(struct new_ascii_header) + fdh.namesize; + tmpsize += NPAD_BYTES(tmpsize) + fdh.size; + tmpsize += NPAD_BYTES(tmpsize); + tmpsize -= sizeof(struct new_ascii_header); + + /* + * copy the remaining bytes to have a complete cpio block + */ + ret = cpfiles(fdin, tmpfd, tmpsize); + if (ret < 0) { + ret = -EIO; + goto no_copy_output; + } } lseek(tmpfd, 0, SEEK_SET); offset = 0; diff --git a/include/util.h b/include/util.h index e1350633..77da1b17 100644 --- a/include/util.h +++ b/include/util.h @@ -33,7 +33,6 @@ #define AES_256_KEY_LEN 32 #define HWID_REGEXP_PREFIX "#RE:" -#define SWUPDATE_ALIGN(A,S) (((A) + (S) - 1) & ~((S) - 1)) #define BOOTVAR_TRANSACTION "recovery_status" From patchwork Tue Apr 30 12:43:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Glembotzki X-Patchwork-Id: 1929494 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=mfhIMK/V; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Ym22Yd+8; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23c; helo=mail-lj1-x23c.google.com; envelope-from=swupdate+bncbdy5juxlviebbigpyoyqmgqevmncfaa@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lj1-x23c.google.com (mail-lj1-x23c.google.com [IPv6:2a00:1450:4864:20::23c]) (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 4VTKdg0pLhz20fY for ; Tue, 30 Apr 2024 22:44:23 +1000 (AEST) Received: by mail-lj1-x23c.google.com with SMTP id 38308e7fff4ca-2d9ee5db226sf50339871fa.1 for ; Tue, 30 Apr 2024 05:44:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714481057; cv=pass; d=google.com; s=arc-20160816; b=tfNQcVKtH3BWe8/vWbyHp0MjQrmFT86Mrm9sRvJ79Gn21WuPUUrSk+DSMq1jGc11ya 6GOiaeZ4uZ0UrhahI86vAiOQ+J9LcaZ5TiU0GatCjF7CamxQ3wsKhyv5Ncciyd4ComGJ x4B0jKtLFUmAUO9QsHQmqNxAyfpDrYfqJ2kFr3p33+rgRv/4pt/aAiJGHDEZkUloocc/ +VlksKCH+wyGdusbp1WEpq/ufgnHKiAK/bBCVEjwECBtKL0+qkMCWZtKG5lJgpydVP2i otPr+2ZVDEkE4zu8EoZqjUgzx/oeYfYXLqyB+NLr+ZV3XMJkgocJtUnx+v03C9j2xCk6 JsIg== 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 :dkim-signature; bh=G02aoHZNdnHCwN2F2NBXYcXrOoujO94dS5tvIoSIJmw=; fh=/HyuDdmhjITRQNWUUyWNDxmSb7UtXynDx7yQUS8kZOA=; b=rLVP5mOqtLXllpNLq5UfKf/Ae05LYAV8jaLxg2NJfWNbCKOnTwXAtx04yOJ0Bx5umu umV608tYz4ZLRXLShqxb3T0C9+1ElF9G++CWsSegT+hE5cAlYZGPM7ibhf6npH9HK1Lm tSymmUpggLdjLiN+RvMVdVERTY/w2wi8sXbFKCzkQWEvXNf7tqMjHnHSweRDTdrxZTQU mNlH3sr8Zez9uRJseg8ekaiqcSrUuPZaGxR37GS9UC5fJTc5dvt+t16QtWrnY+aNUeud pQhUFSl+Wd6wUHqmhUm1GKgcvmAIuSlLj7t84RlAdkhtToL0GZToWIvPXrWYxWok1uK+ 3k1g==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=a1Ppnt4A; spf=pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::531 as permitted sender) smtp.mailfrom=m.glembo@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1714481057; x=1715085857; 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=G02aoHZNdnHCwN2F2NBXYcXrOoujO94dS5tvIoSIJmw=; b=mfhIMK/VvnTi7KWuPk7ARRNvCBTQRrmquxh8WqDGjegpsUQds84DZpUqeNuOxBaWAD JHW4FaZqxsn0HMpvUkAI1/KWOERfNZyp/V/9aqdeM6ERjcpoVjc5rFpoVmqv5FzR95kK cgJ1cUVCtIGW/E7IJUqwHlBxfS0SlZph+oHJgj62tCqd+LZViC5lkb5kudG8LWnun7UO l/wYDiUSKmUmUYEyGqH0v0BJXtiGw2HHuy98jMf3kdDgdLKlrh5Xkx6GU40jSBjn3CJD UVcEsUVugVnDhOxPWR9RAkpTy+5pdFO7n8qeTWURMu64jhSwMcvfkCphXWcoW8zAli35 PUqw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714481057; x=1715085857; 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:from:to:cc:subject:date:message-id:reply-to; bh=G02aoHZNdnHCwN2F2NBXYcXrOoujO94dS5tvIoSIJmw=; b=Ym22Yd+8qvIWcyAPYEVZCshuAH5JtHqrrZf7fTFE4OtX/RiG1i2qKhjmP77PUSB66W SUzosFKNb5EeHxUr0HdodeBpn5MPjzdNgrx5LCF1KLLyg/zKeohzvv0pYn06qFy8zRjK XvgYPs5T0felbfT0iwCqedpldqiagRbHhLI3TLmYKfA1YbFrlR6vj7Tj8Z56VAEwwmyi kGXz4y/ktm13NNV7+QJ1JoqweUmVyL6MIYI+tq/WzAgEZa0JNYUU8+TpoJ8nTU4t6RYb NCDiE5gW2YvuOSkR5Butg4htz77qdgSs5GXL5O7ZntWjeDMRJ6/YGJa65DpaDRoRHRaY V/Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714481057; x=1715085857; 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=G02aoHZNdnHCwN2F2NBXYcXrOoujO94dS5tvIoSIJmw=; b=ci3CHiJrMKmqRGnfxjfd+4SDYm7S02Y64HtkpanXhBptaJ4nscTz2mViSd7d2oVebk PeHCMTm5pt/Z6KMFM/C2L8gYY78lRKehGz1OvUKZi9GC4+QrJd0NUGyCx/7KhCGw+auu B1rslMJVWd822SR1G+Vo2MK/vMdvXIQ6ACmVX9Sf72Pa/c2cOeyYifgj2DUQm7lRPD5e sl+rz+cd4yWm8b3xlCgR1ImHX4exWjtr1iurWEUHh8/q/JZ67sUpQM+eVi/fA67WL9xv zybkxvxmqjqktbaDIBpmpGdD5wNuBCj82Jjn3AP+ag28pu3jzMRztmqiQ/Ch3L7GD7bC Fzhg== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCVNLVm8ykfjcJajbuPurhQY0BbvylldJ00PTNNB5lQlgVDzqspt3YmKzHEGOclnsC4nQG7iMN8HWCZ6XEV7fA03s791gdjwC0L+QmRd9A== X-Gm-Message-State: AOJu0YyYykYHydGzCJxy7Npc35Ck+JqRBbBzoCt8bT1YFDnsWgvijg0n VbkMUsoNdoGrBzH89AUH2MshbSIWdVoxXCChUYz24KpeFDEewBY+ X-Google-Smtp-Source: AGHT+IHoVy/HBK3F2RAm+s3amglUeSwq9uUy49CSiZ8o6hN17C/+Qb1jR1OYn1K9AJQ3BWoPqmfLXA== X-Received: by 2002:a2e:9e01:0:b0:2d8:67a0:61b2 with SMTP id e1-20020a2e9e01000000b002d867a061b2mr8384018ljk.20.1714481056994; Tue, 30 Apr 2024 05:44:16 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:9658:0:b0:2e0:1a91:ca69 with SMTP id 38308e7fff4ca-2e01a91d1c4ls8970421fa.0.-pod-prod-04-eu; Tue, 30 Apr 2024 05:44:14 -0700 (PDT) X-Received: by 2002:a2e:834e:0:b0:2df:66f6:e418 with SMTP id l14-20020a2e834e000000b002df66f6e418mr8705092ljh.21.1714481054038; Tue, 30 Apr 2024 05:44:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714481054; cv=none; d=google.com; s=arc-20160816; b=GszIyEbrjRPXyQsHfbCFqwUgWm183eeyEMSIcMutNRik917YB9Z1lIaQMGbihOZjDy yp+8IX/WwNgHSxUEOKuA6nELP8ChoU5qnfQDBsH6tIGFdsptqcSF5fp2LcEJ6JPrjpWp e6g+CmWZy+Wz7OrlUjvcqFteA67OAJwzkUT7+gbphtZYNtduGRNgCbP6+i8h5eKYiID0 WW0gltHHOyfUdFiuBmQavc1acM0wjjc+nhj5nKRh29WzX/AXRl3+ftsxWbcfO3AnNHin xQyJpwjN793KvNSsld+LcREp6dHvExe+OvFXfYJKpY5plNeWlFz7dyaZGXOpQvqaMWq9 6K0A== 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; bh=dJ5LEVaBhdhS7sb5orPEhntOh38xiGVpd3KFAqqhAJo=; fh=zydHuzCQWrku2OPQyZfraJZFcOpEXLQ/YBcu3QNiBd0=; b=OM5Ogan0byN4CEklLzLJ0tKf96aFUwNkMnJDmunVvAfJhsJ43t9pOohnVcw27dv7xX hfpVVxo79BSk7NLhBsxuYWuiffhdRth6QAqVhHduj5QHX5Y6Hg7o+Ij+ORUcvkaJ1+b8 pwKxGIUnPymuIKc/ZPhcFuoXBcHRjgPT6D+7gGHCzzL7vtPMn27oqMUaMaEcIAbzykXd hwf+rcCxo3keXMTGw5iBRRpMsOjJjqzkxCgJtoFo53LI/DufR4A7gRC1miiGd0rnu1p/ dm7VI4Gebez1JVM1Oh1eDfqxJp0II8XxTT4mlR06qJjN7vYk1DjsiIpQd5vOhURABv5w 5jKw==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=a1Ppnt4A; spf=pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::531 as permitted sender) smtp.mailfrom=m.glembo@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com. [2a00:1450:4864:20::531]) by gmr-mx.google.com with ESMTPS id s17-20020a2e81d1000000b002d85301f1dfsi979982ljg.2.2024.04.30.05.44.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Apr 2024 05:44:14 -0700 (PDT) Received-SPF: pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::531 as permitted sender) client-ip=2a00:1450:4864:20::531; Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-572669fd9f9so4742452a12.0 for ; Tue, 30 Apr 2024 05:44:14 -0700 (PDT) X-Received: by 2002:a50:d74b:0:b0:570:2198:b3ca with SMTP id i11-20020a50d74b000000b005702198b3camr10424016edj.14.1714481052673; Tue, 30 Apr 2024 05:44:12 -0700 (PDT) Received: from localhost.localdomain ([2a02:8108:96c0:76fc::3f69]) by smtp.gmail.com with ESMTPSA id a101-20020a509eee000000b00572459a4ffesm5869281edf.56.2024.04.30.05.44.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 05:44:12 -0700 (PDT) From: Michael Glembotzki To: swupdate@googlegroups.com Cc: Michael Glembotzki Subject: [swupdate] [PATCH 2/3] cpiohdr: Expose Makro NPAD_BYTES in header for external use Date: Tue, 30 Apr 2024 14:43:15 +0200 Message-ID: <20240430124316.1714467-2-Michael.Glembotzki@iris-sensing.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240430124316.1714467-1-Michael.Glembotzki@iris-sensing.com> References: <20240430124316.1714467-1-Michael.Glembotzki@iris-sensing.com> MIME-Version: 1.0 X-Original-Sender: m.glembo@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=a1Ppnt4A; spf=pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::531 as permitted sender) smtp.mailfrom=m.glembo@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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: , Signed-off-by: Michael Glembotzki Reviewed-by: Stefano Babic --- core/cpio_utils.c | 2 -- include/cpiohdr.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/cpio_utils.c b/core/cpio_utils.c index 7948dc2d..87847981 100644 --- a/core/cpio_utils.c +++ b/core/cpio_utils.c @@ -31,8 +31,6 @@ #define BUFF_SIZE 16384 -#define NPAD_BYTES(o) ((4 - (o % 4)) % 4) - typedef enum { INPUT_FROM_FD, INPUT_FROM_MEMORY diff --git a/include/cpiohdr.h b/include/cpiohdr.h index c909af94..b694de5e 100644 --- a/include/cpiohdr.h +++ b/include/cpiohdr.h @@ -29,6 +29,8 @@ #define CPIO_NEWASCII 070701 #define CPIO_CRCASCII 070702 +#define NPAD_BYTES(o) ((4 - (o % 4)) % 4) + struct new_ascii_header { char c_magic[6]; From patchwork Tue Apr 30 12:43:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Glembotzki X-Patchwork-Id: 1929495 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=HyO8TpCN; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=kiXXc8KB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23d; helo=mail-lj1-x23d.google.com; envelope-from=swupdate+bncbdy5juxlviebbiopyoyqmgqe4rzfa4a@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lj1-x23d.google.com (mail-lj1-x23d.google.com [IPv6:2a00:1450:4864:20::23d]) (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 4VTKdg2mbGz23ny for ; Tue, 30 Apr 2024 22:44:23 +1000 (AEST) Received: by mail-lj1-x23d.google.com with SMTP id 38308e7fff4ca-2db099e687fsf47792911fa.1 for ; Tue, 30 Apr 2024 05:44:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714481058; cv=pass; d=google.com; s=arc-20160816; b=H/U0a1QggByDqB+7vWVs17RfsirQhmsmKbLaD2L++VsRgDwWBySJ3EJw1TycLQ1bSq Lh5+idJ9Iarqb4sbfPhUmeeGWN1QXx8id/UkYMCAPxjJyE0AP2aO21+Rzhnmqzauc4T+ qgRDtyp7LhV2xB/e15Tcrx/fSpnpnuOd4mNJAgG870z3hOdTJzLgoZjNjdBO0bbAFDsx qnbyA4T7+QeFvldBoW3VTnmODnME5WkoUv1TOS0bTxOkuIUvNWOKZ+SoOnZrin6L/3aV 1kVHyFsAUkrJKnYLpS++Wpfi5M7erq+OkhMtqIOJmBcy8+PsIRYjxNjQvAQ/NAROhKz2 Scdg== 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 :dkim-signature; bh=CKmgZTL3E7qFXhxziOvb4BIdRfTcugpvq70XwmvjxWk=; fh=WiV/DuhyjPS0GOgrfuPbD/Sd56Ap8rHAX6IOzcviwaI=; b=u92HDoSGqQvCk1fEGWu4HzTUtyDss008e8bZjn+Vi7tVhVflHLAYCWVv0Prxirz+bR g0OL0VVseqyXRvOrRQrjm1YQIfgGEgfuNepWYhm1ADmndC0NcHIVTCJQ81HtnHuXB5EA fpoVc4NvvramNVjo+hmhEp3gGRRsvT6umklo3rZ6blHDXXa5ZYkGkaGprASmopqA4Osk J7ufn8Aw8kW+hGHlrtcxNqbQI0FggcB58XhobdgWvNj8THjJcpAG+C/G2HZGtc3DOLrG sAnfCRyhuVhRSdUP7KEgOpLqAoo7yALt/8jrNa3in2VY2lukytweBSnzTQiaCfPtza7f vbxQ==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SSF0jKZg; spf=pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::535 as permitted sender) smtp.mailfrom=m.glembo@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1714481058; x=1715085858; 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=CKmgZTL3E7qFXhxziOvb4BIdRfTcugpvq70XwmvjxWk=; b=HyO8TpCNcdrugm4njwFf+DsHltI1U30CgMVHJhPO58PveeFouv0v1jp97Aay+NMgzT pFeiLT5P6TESEKSwRZUEcUvi39c8WT7wJ24b5J78Vlr1D1Uk8IoFuIZ0sh2B83YiQh7/ nGrR1XCAAVxTm0X4BuPTYtE4mc7ehXovc2VuHsdsU2ABErpGCOliWCaKZmKJmNdVGICV zgZv0SljzvspX0OxRlu9j50On8JKA1IETrMoFBShf1NZqwR3IFZvvsxXPxqzhLuA6DB1 gvet0drY1desiE7M15oHNVVBSdoiMBk+yIALqTo79MnJuiXEo6bEdOCBbTvhhFfZkGh2 8d2g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714481058; x=1715085858; 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:from:to:cc:subject:date:message-id:reply-to; bh=CKmgZTL3E7qFXhxziOvb4BIdRfTcugpvq70XwmvjxWk=; b=kiXXc8KBJL40p/7ZyoM4y7wovbCeIwgE79/mHDoJ64+OLlotWnj7sIVlsEnV20DbeS iB+PIDmlyFxzTulZNDYM2Z2/TYHVZWKClV16gmOkHssHT6gvtAv4moneduGKXxITvpjE FOA3kqZYb5w+wzfCbRi5/7E+9Zu747iG7yROzRS3H5Vx1GdrV3sM4vqcRi5mjr5Qb5m5 TV+WFsFwvvsziAWIXaHSWB1iPqIVVhUrPmhUbu05qY8X/9TXEzLqnoU7HbakQlPd2vlY flLp0x9dbYlcfXGDU3nneEWOfnAuj4ulDsNXun9sJwgIeDCZqjw7sM6y2S6Qu/z4CXgZ XRlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714481058; x=1715085858; 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=CKmgZTL3E7qFXhxziOvb4BIdRfTcugpvq70XwmvjxWk=; b=s1UEFEpSrqxj4+KVovyVL7oAsuJpm8hgkHLp/381OHpqQ8btap9LUxuWR+t3ug8dmR /ar6BACQWkiOyzF980ROQQKEYxWw4avqc1DqQz9RgXibGhm+oY3uP6guBw3fKFrVsSKJ 7tlkGLvs9RbLkRjV2W34Ok6uyH4wvoLi0fyyiO6webU68vzuegQRlQC+ZlwZmZVuIR7F 7u/A645J+dKV7Q9OD6O3SwqHWQN2Cbr1RJAB2plqQD2ivym848SWk4vzeMKCBiai/CoD C/KXPwaZ9P+dY2K3uCiE+qvVFSlHYsIiGGOjYKdQXWBdK9q7kRSZjvSY8YA7mk0O9UQB 8Kmg== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCU22+oydQeTB0QEuTPgO1sHzsIwRK2+eEcCPHQfkNI3MOefwmjz+Gu9zV8/uZRC+EiFYLzCZi9m69Sl9yLVE0dGuRYFeZyG2zbKDu9uSg== X-Gm-Message-State: AOJu0YxTDJ/vt/cC40pJE3wRsNtPnCkaiQTraqBgLVp594AA7rEvkyn9 DcvAEKvbaOLb9njYwU9A8DGVPcJBrVJo6ldScqA3qWmSmU/F33YP X-Google-Smtp-Source: AGHT+IG3QWWxH+wL1YFu35sgqC0vqU5tYhMzelJurEO2JCsbD0ZGOouodTrrFW+sMKRAcHyn2FZmDA== X-Received: by 2002:a2e:b6d0:0:b0:2e0:efe5:4cda with SMTP id m16-20020a2eb6d0000000b002e0efe54cdamr1423766ljo.36.1714481058355; Tue, 30 Apr 2024 05:44:18 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a5d:6a86:0:b0:34d:8c0a:9169 with SMTP id ffacd0b85a97d-34d8c0a975els203973f8f.2.-pod-prod-02-eu; Tue, 30 Apr 2024 05:44:15 -0700 (PDT) X-Received: by 2002:adf:b195:0:b0:34d:7fbb:e15b with SMTP id q21-20020adfb195000000b0034d7fbbe15bmr1253460wra.27.1714481055398; Tue, 30 Apr 2024 05:44:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714481055; cv=none; d=google.com; s=arc-20160816; b=PQ/xVnKt9bMxwH0oVNWNPLNeBD5vgN4mDLuq9/Ct2s6tmtFU/4i7FbEhs9hmJS6MBT aIwBoMkKpezrxQiF5vYq6AMZof89dEC+q13IpC5xha219vUnjoSJCK2H2KW7Cn9x6r7l g5xacg1pjkiOE4MxfsvQfS9toQTD3Ux1Y+CE2g6dHLCzg5hM65KIKOrwTo61SMd0TTGZ aaV38RI+nGjfzkIMtBrSbG2RJe3r0bxSMldeQ/ivM+W5Yzv2RCLo505DZYik/47kOj1m mWJwgApT9erI3xCDr7nLsRRYYkqxXw+YA674QH+5nUK0kWMmPUtCAg9hn2H1+adxmudk NPFQ== 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; bh=8DTxCXSyvMU6qKstuBDWNz3FOwZ9u/0AEc5Amsm6cGI=; fh=zydHuzCQWrku2OPQyZfraJZFcOpEXLQ/YBcu3QNiBd0=; b=w1SOUbMfV5X0v2ERTwh6Fp7hNehQ6QunVCo6LGL7WL1esm2ugo14NlaXdoL6GmZFC7 YV1lMuYihVBIuupgC8lfNGOquvuczzHtC2rMF/VtadcOJ2fb52po4mD7xTOPnWzg9pkd rj1f6NJawsN2riBNcUwV8MpcBMMOF2kl5D2h5/E6Pdnae4FRfOxQG7lirjr4Gn5vRRqz liNyYlG69DmOUcgbDMAxZJ2Z6MiFN1krtde45ePQENdfJrceyXSbSxKZYiwvHhGgooi4 VlgtFYBLs1ZGIopUFABcVawmwiN5/7h8/PmV1bcNP2q2TyRh6VeObwCqdvrjc/r6i8VU Ym+w==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SSF0jKZg; spf=pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::535 as permitted sender) smtp.mailfrom=m.glembo@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com. [2a00:1450:4864:20::535]) by gmr-mx.google.com with ESMTPS id cw18-20020a056000091200b00347a3498f11si965065wrb.5.2024.04.30.05.44.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Apr 2024 05:44:15 -0700 (PDT) Received-SPF: pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::535 as permitted sender) client-ip=2a00:1450:4864:20::535; Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-5727dc6d3edso2774569a12.0 for ; Tue, 30 Apr 2024 05:44:15 -0700 (PDT) X-Received: by 2002:a50:cd9e:0:b0:572:6846:b899 with SMTP id p30-20020a50cd9e000000b005726846b899mr1864460edi.41.1714481054260; Tue, 30 Apr 2024 05:44:14 -0700 (PDT) Received: from localhost.localdomain ([2a02:8108:96c0:76fc::3f69]) by smtp.gmail.com with ESMTPSA id a101-20020a509eee000000b00572459a4ffesm5869281edf.56.2024.04.30.05.44.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 05:44:13 -0700 (PDT) From: Michael Glembotzki To: swupdate@googlegroups.com Cc: Michael Glembotzki Subject: [swupdate] [PATCH 3/3] cpiohdr: Expose fill_buffer in header for external use Date: Tue, 30 Apr 2024 14:43:16 +0200 Message-ID: <20240430124316.1714467-3-Michael.Glembotzki@iris-sensing.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240430124316.1714467-1-Michael.Glembotzki@iris-sensing.com> References: <20240430124316.1714467-1-Michael.Glembotzki@iris-sensing.com> MIME-Version: 1.0 X-Original-Sender: m.glembo@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SSF0jKZg; spf=pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::535 as permitted sender) smtp.mailfrom=m.glembo@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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: , Signed-off-by: Michael Glembotzki Reviewed-by: Stefano Babic --- core/cpio_utils.c | 19 +++++++++++++------ include/cpiohdr.h | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/core/cpio_utils.c b/core/cpio_utils.c index 87847981..00b15f03 100644 --- a/core/cpio_utils.c +++ b/core/cpio_utils.c @@ -59,7 +59,7 @@ int get_cpiohdr(unsigned char *buf, struct filehdr *fhdr) return 0; } -static int fill_buffer(int fd, unsigned char *buf, unsigned int nbytes, unsigned long *offs, +static int _fill_buffer(int fd, unsigned char *buf, unsigned int nbytes, unsigned long *offs, uint32_t *checksum, void *dgst) { ssize_t len; @@ -92,6 +92,13 @@ static int fill_buffer(int fd, unsigned char *buf, unsigned int nbytes, unsigned return count; } + +int fill_buffer(int fd, unsigned char *buf, unsigned int nbytes) +{ + unsigned long offs = 0; + return _fill_buffer(fd, buf, nbytes, &offs, NULL, NULL); +} + /* * Read padding that could exists between the cpio trailer and the end-of-file. * cpio aligns the file to 512 bytes @@ -235,7 +242,7 @@ static int input_step(void *state, void *buffer, size_t size) } switch (s->source) { case INPUT_FROM_FD: - ret = fill_buffer(s->fdin, buffer, size, s->offs, &s->checksum, s->dgst); + ret = _fill_buffer(s->fdin, buffer, size, s->offs, &s->checksum, s->dgst); if (ret < 0) { return ret; } @@ -669,7 +676,7 @@ static int __swupdate_copy(int fdin, unsigned char *inbuf, void *out, size_t nby } if (!inbuf) { - ret = fill_buffer(fdin, buffer, NPAD_BYTES(*offs), offs, checksum, NULL); + ret = _fill_buffer(fdin, buffer, NPAD_BYTES(*offs), offs, checksum, NULL); if (ret < 0) DEBUG("Padding bytes are not read, ignoring"); } @@ -757,7 +764,7 @@ int copyimage(void *out, struct img_type *img, writeimage callback) int extract_cpio_header(int fd, struct filehdr *fhdr, unsigned long *offset) { unsigned char buf[sizeof(fhdr->filename)]; - if (fill_buffer(fd, buf, sizeof(struct new_ascii_header), offset, NULL, NULL) < 0) + if (_fill_buffer(fd, buf, sizeof(struct new_ascii_header), offset, NULL, NULL) < 0) return -EINVAL; if (get_cpiohdr(buf, fhdr) < 0) { ERROR("CPIO Header corrupted, cannot be parsed"); @@ -771,13 +778,13 @@ int extract_cpio_header(int fd, struct filehdr *fhdr, unsigned long *offset) return -EINVAL; } - if (fill_buffer(fd, buf, fhdr->namesize , offset, NULL, NULL) < 0) + if (_fill_buffer(fd, buf, fhdr->namesize , offset, NULL, NULL) < 0) return -EINVAL; buf[fhdr->namesize] = '\0'; strlcpy(fhdr->filename, (char *)buf, sizeof(fhdr->filename)); /* Skip filename padding, if any */ - if (fill_buffer(fd, buf, (4 - (*offset % 4)) % 4, offset, NULL, NULL) < 0) + if (_fill_buffer(fd, buf, (4 - (*offset % 4)) % 4, offset, NULL, NULL) < 0) return -EINVAL; return 0; diff --git a/include/cpiohdr.h b/include/cpiohdr.h index b694de5e..18107c17 100644 --- a/include/cpiohdr.h +++ b/include/cpiohdr.h @@ -62,3 +62,4 @@ int extract_cpio_header(int fd, struct filehdr *fhdr, unsigned long *offset); int extract_img_from_cpio(int fd, unsigned long offset, struct filehdr *fdh); void extract_padding(int fd); bool swupdate_verify_chksum(const uint32_t chk1, struct filehdr *fhdr); +int fill_buffer(int fd, unsigned char *buf, unsigned int nbytes);