From patchwork Tue Jun 6 13:17:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Potenski X-Patchwork-Id: 1791166 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::b3e; helo=mail-yb1-xb3e.google.com; envelope-from=swupdate+bncbcdm5inazqbbb5xd7srqmgqedbrvwvq@googlegroups.com; receiver=) 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=20221208 header.b=EseCNqlN; dkim-atps=neutral Received: from mail-yb1-xb3e.google.com (mail-yb1-xb3e.google.com [IPv6:2607:f8b0:4864:20::b3e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qb9y40HChz20WK for ; Tue, 6 Jun 2023 23:17:46 +1000 (AEST) Received: by mail-yb1-xb3e.google.com with SMTP id 3f1490d57ef6-bacfa4ef059sf9796990276.2 for ; Tue, 06 Jun 2023 06:17:46 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1686057463; cv=pass; d=google.com; s=arc-20160816; b=0rI22d5to80ilG52YCzf26ICnHl2+2Gi8AXtbqb+hMgDq5Z91uDNIVu+mT7tqA5kJn kJ+ksQlFklVHhbkF/z4SP8IHqSyDMpGPiZQkXGjnzlB6bug2jTBz2gfO1AdY8RuW0HHX BlwRJ9E8AY81yU1NTiFwHj1d9jDR0t01y5YQPdbost2NoQ9APV3PsfL550NPSTCP7lSe MG9A38qsex97GPRWGj7sczbq3VEt805mWyJ2K8X2G+/Opx7q5EF+Ld/YTzFAY8G9AWzi /XBeiydx1zFX7GLBvWJVV9s+wP2xBgjJIFnjAstsn6kbld8gjmUV9fcj5E3Ho6dR3lNr WTGw== ARC-Message-Signature: i=3; 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:reply-to:mime-version:message-id :date:subject:cc:to:from:dkim-signature; bh=0pUGtg9ATv0cFqwFRmBJDM2vfFkbp2ew2PnInoIwKcw=; b=WKCFnivYZTYnRerDIWMcA47sbuG9s0ySnwquRAZ6flm2mqGDhlU3yX4OseG4TJR5rv n0MuPLY6igNa1+p7UT0HM9UPlGpsX6VEwi3mcTS3sBGSaF6KLa1c5gClalBNpOBMoF2q nvBCZBguKL3u5xu4nOkcjLu7s8SHAxquZbgFngIeP88QBcTCpfZ5KXKVQ+oKDoR5sKJa 4ibUZITd3JToBW8Y4wczhaYJq8cwoxX56qjk0mmLG5o1x3Bm0n7PwRfOaxADXe692HQY TrbD+XFNJxVAK5+VvUrxJoiZV1Ultw6hMdBqD8vXD7IMSWDOk3IaZ8H2Op3UP0kzJ7jR DJAQ== ARC-Authentication-Results: i=3; gmr-mx.google.com; dkim=pass header.i=@garmin.com header.s=pps1 header.b=G0dw1KBV; dkim=pass header.i=@garmin.com header.s=selector2 header.b=C42K9uTz; arc=pass (i=1 spf=pass spfdomain=garmin.com dmarc=pass fromdomain=garmin.com); spf=pass (google.com: domain of nick.potenski@garmin.com designates 205.220.165.212 as permitted sender) smtp.mailfrom=nick.potenski@garmin.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=garmin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1686057463; x=1688649463; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :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=0pUGtg9ATv0cFqwFRmBJDM2vfFkbp2ew2PnInoIwKcw=; b=EseCNqlNtSCKf1HtmpApKjNYgkWOgm6Ldz5UwkdNVpov53ugGUk2DH/XvqxGrtTWkr rqrNhQv6QyToSMoNq5d0cbjzKxVPvY6PCOYsWnPz8geb1DgTE/r1bXxsPbFvxOUKTyIm ZfucNElZ6v8EdupITulXFbs6HaBm8Xsxq6AtU7Di3MT4u735i05u1sHtcETQYdeRo/ED w5t0EpamN/5klfNUDUgwrOEvKqepOavug3As/ZoRrCuUkIdVGmVaUTD6NMYhJ4FDjMoC JMeVM9u1mqPD1pwN8dF4aF75XMM60bNuefgJ2Cn4jkgnj6YYuRIHV7y+fsQTW6uZwa7v XIFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686057463; x=1688649463; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:x-beenthere:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=0pUGtg9ATv0cFqwFRmBJDM2vfFkbp2ew2PnInoIwKcw=; b=Q+hysxv+s5k639a7R9c+NXQzwSAqviNIdg3S03JKPRMjYc1sFyvQ6PzUIN9+EP8c0p FKZX8QSm2sQ0kTW3chpazFKjC4HCB2HtxgtHheBaNdmgcVogL3+YU4NT4qT2KDY7orZk 8nGvnEh8nuZ5hoqRwiQk5bR/tStmxUrys0BqxYC4GYqFf6OIvdVbiMZnZBE6yXk1WACs akT/Wv86X091/fYQ5JQtRfZyT3QXub1uC93FzKpjCVLQMsN2O4X3CZIJZfe3IQJp0BiC eQGd8RdKdc2QH2p48X6kxcmnpl2ksad8F70LDlasIBTt1ebj1uefZyRjUg1TE19qMxTM HDKQ== X-Gm-Message-State: AC+VfDx+7edJaYu7Lb5qxRvv1TDdD3aDUMXE5LiCqLv0Llwj2IubS4lI HsWCycFyoK0iis9c8CU+LQw= X-Google-Smtp-Source: ACHHUZ4wScspbJWbzSL4cOZ5rpzGfNXVx7JYLLVdu0mrhSDuulnxxdLa4papbEKXjVNzTBSdMOjjng== X-Received: by 2002:a25:b287:0:b0:bac:69be:9495 with SMTP id k7-20020a25b287000000b00bac69be9495mr1823247ybj.31.1686057462846; Tue, 06 Jun 2023 06:17:42 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a25:5089:0:b0:bb3:90be:c250 with SMTP id e131-20020a255089000000b00bb390bec250ls105457ybb.0.-pod-prod-06-us; Tue, 06 Jun 2023 06:17:42 -0700 (PDT) X-Received: by 2002:a25:e789:0:b0:ba7:3ed2:4e35 with SMTP id e131-20020a25e789000000b00ba73ed24e35mr1596207ybh.40.1686057462106; Tue, 06 Jun 2023 06:17:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686057462; cv=pass; d=google.com; s=arc-20160816; b=JWo2iT2i/gEgoBOhpziuZOtY+pWs/bY0rUtIJwG0n+eLxK6n0vQVyXPlzq5uxu4N+B 0glcAgitEwnTzdF7wCuWL305Vvv/U8T2WJjIfqny0kf2mTpaTL2XYg2y5iKnhWDa0DQ4 zqaUHqoaOj/YuET5d9YK6sbaTkW60m2q+jyZZ15Kd32UY603YV3FYob7+WzX82QJ0huw PHPwV9KVBCFrc+0GakqqIvSxSiLo5xpfzWOleb/zAS2h019oGzeg09k7J0Azjy08Aqjm I0nYhh78J5OMh/Th/AEhmhko6TMZXzMBPDBpssZFOVEHBQ7vZxMEEwxI5saoBsJENmzD gT0A== ARC-Message-Signature: i=2; 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:dkim-signature; bh=Z2dKIO6/V7SdmiPSanG5po7k8MvACCSzMVGvXNTPh/g=; b=xQ93QMTKIG2XiNMDhw+ZOZTLd5zBYDsc7irC5Y7fq3NC1zwqsJUSpjGuu/e1NkWPhL Nd2dDRUN/0MMugYt+IlsAJDoWLS+XbfVETMZ2K8LEJV1+J1uMt0PtZGCMCxwU9gjWLU6 2kbBHMtXqhD70X68pkNcgpK7rVzcGLQrA1+cHsbMWh1h/ItwJzurzcURESi7Fv8Ds3Me 1peLtXaW3r/MG300lz2jfys1LLmWNuZ7z0ERoV8fV7nKGgyTU/zUXIGKfiEM5XXOJBI+ K4sEx4uDv1fEm8T0GZuIZsMR/CBkvQGEWreugI43LW/RadjjuOLLemwtLNw17VLRFovb e4lQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@garmin.com header.s=pps1 header.b=G0dw1KBV; dkim=pass header.i=@garmin.com header.s=selector2 header.b=C42K9uTz; arc=pass (i=1 spf=pass spfdomain=garmin.com dmarc=pass fromdomain=garmin.com); spf=pass (google.com: domain of nick.potenski@garmin.com designates 205.220.165.212 as permitted sender) smtp.mailfrom=nick.potenski@garmin.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=garmin.com Received: from mx0a-000eb902.pphosted.com (mx0a-000eb902.pphosted.com. [205.220.165.212]) by gmr-mx.google.com with ESMTPS id b7-20020a5b0b47000000b00bacfd3f95b9si469716ybr.0.2023.06.06.06.17.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2023 06:17:42 -0700 (PDT) Received-SPF: pass (google.com: domain of nick.potenski@garmin.com designates 205.220.165.212 as permitted sender) client-ip=205.220.165.212; Received: from pps.filterd (m0220294.ppops.net [127.0.0.1]) by mx0a-000eb902.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 356CXVZa004084 for ; Tue, 6 Jun 2023 08:17:41 -0500 Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2104.outbound.protection.outlook.com [104.47.55.104]) by mx0a-000eb902.pphosted.com (PPS) with ESMTPS id 3r2355g7rq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 06 Jun 2023 08:17:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OacnD1JLApT8HJC6yULNHLZUjc6VGGItQ+8CyZVtj2+NGFYOhiHKbYTpuYn8TMkuZIOF5EUgDs3zfcARaFLk62EKIiwVENkZwXCwCDIugG9RalU1VYatSmHTcI/GxJUuxIMkbkr+Mc3vTRznL+YSnBFohlHuC2DwbynAaONNowKI4excMO6+ZX4XKAGKjl/Ae0/2xm09x8dVuvij3ofaw2jnau8IxEFaSDqrv7jy8nvYLfwJngksAMXdGJ1/XaPh/eTU/Bu2cASfF1g+mUzm4PCUaGy7Vo/0/8svG82KJIXqBDQzgyucMHD/VUPIXgK8yfamGss0sBdhmT/H+Jaevw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Z2dKIO6/V7SdmiPSanG5po7k8MvACCSzMVGvXNTPh/g=; b=YJ4TtP9wdDmzKAJE2KDvPA5JoX0O2K6rIy7b4wwPl3tZpT/zc/N527M7gvFz3oDmvgp9Oa+1pkJfbb4OVt9p2iSIatTmatCcaozDdjO6GsIZuTqi7024JHLhJgZDOmLYWds+pseO6f23WRLFyOQaO2Nt56oF80nEPOfmrUtKJ9DiMXlyMdlSS+nQyKC+Sd+vtBJa+vMmvOfSQ/AyH/p/IniR5cgOPuT/eyP7QU2K+G1hfjPydcQepBGdcF/wpIY86S81CQjxI4tyATSJHGv+/QjhLrOC4xP7+FT7ybC2KYgMJAzUdY/k8UTy0IBW/bs7cbGIf+lPQe7iDoQVSTo9Eg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 204.77.163.244) smtp.rcpttodomain=googlegroups.com smtp.mailfrom=garmin.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=garmin.com; dkim=none (message not signed); arc=none Received: from MW4PR03CA0101.namprd03.prod.outlook.com (2603:10b6:303:b7::16) by PH0PR04MB7770.namprd04.prod.outlook.com (2603:10b6:510:e3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.19; Tue, 6 Jun 2023 13:17:39 +0000 Received: from MW2NAM10FT059.eop-nam10.prod.protection.outlook.com (2603:10b6:303:b7:cafe::42) by MW4PR03CA0101.outlook.office365.com (2603:10b6:303:b7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.36 via Frontend Transport; Tue, 6 Jun 2023 13:17:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 204.77.163.244) smtp.mailfrom=garmin.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=garmin.com; Received-SPF: Pass (protection.outlook.com: domain of garmin.com designates 204.77.163.244 as permitted sender) receiver=protection.outlook.com; client-ip=204.77.163.244; helo=edgetransport.garmin.com; pr=C Received: from edgetransport.garmin.com (204.77.163.244) by MW2NAM10FT059.mail.protection.outlook.com (10.13.154.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.19 via Frontend Transport; Tue, 6 Jun 2023 13:17:38 +0000 Received: from OLAWPA-EXMB1.ad.garmin.com (10.5.144.23) by olawpa-edge5.garmin.com (10.60.4.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.6; Tue, 6 Jun 2023 08:17:31 -0500 Received: from kc3wpa-exmb6.ad.garmin.com (10.65.32.86) by olawpa-exmb1.ad.garmin.com (10.5.144.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 6 Jun 2023 08:17:35 -0500 Received: from kc3wpa-exmb3.ad.garmin.com (10.65.32.83) by kc3wpa-exmb6.ad.garmin.com (10.65.32.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Tue, 6 Jun 2023 08:17:35 -0500 Received: from OLA-J986JV2.ad.garmin.com (10.5.209.17) by mail.garmin.com (10.65.32.83) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Tue, 6 Jun 2023 08:17:35 -0500 X-Patchwork-Original-From: "'Nick Potenski' via swupdate" From: Nick Potenski To: CC: Nick Potenski Subject: [swupdate] [PATCH] Fix calculation and reading of end-of-file padding Date: Tue, 6 Jun 2023 08:17:33 -0500 Message-ID: <20230606131733.61216-1-nick.potenski@garmin.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW2NAM10FT059:EE_|PH0PR04MB7770:EE_ X-MS-Office365-Filtering-Correlation-Id: a80fb935-330d-4cee-5d99-08db669066d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wdSH7rxv9ZfpCTQPkyG398fN2R3j2opYupLDDkLj3vpdwJhxv6DsTxIHCyxOf7au3uqkl0JH0q2O5g/u1NnxlPGdvH9WRk71r/8C4W+rHNeabZvg3Co86tq2dqM9LkC+cnpw30wrZ8K2SKrRTbB5mzFU5aPjmOpxJow943Ly82X0OUPvID/ucWZEIUcbGuyuwWyvLHMCFE1jP/jSxArTif41KuolLwPjz2g4McqVz9NRgL/RcI2HwMD+qfnch4xBTv/gubcqrPF3UfgOwbJGA3tVLBlvCi6WONNFrxxYOpXwVTM53pbGazw05fdAzEdXBCH5MGB9tXDmO3dH0kleuQ0hJgKVgwFCkWygrpEaOC7eK3dsE+N4lbFs6+rJ5ZoZhbyIewEf/H2I4Vi/uIomPW1B34MLymHh8LokhEQVkq6n7g/bDeOWXsLwsiN5N5S3NKTK4eqneMYLMdC6nNroNZoJgLZPuBt20aBYVEuUUOl2rHyOY8+yz1hxkVEE3zckgn4SIJ6S44ooA0Kvw30tohurCOY6KRvzHxN6yJVaCpNA+lKOmQk28PWbCusUBFTH7gg2qCBjQTCPR1q4Q2G+t2eBkfghczgjxVPmEXkF1MvYfL3fvj9LnA9tVOu3CKXUP43Nw8lw8s/ujjBmWEMabw2d28+9R8ro9BjXwPYjhPMYpiFvIatiJtpAnKX/PZ/4CImBgHYZGX3Mc3+BvrS8mG3EoHgz8vLTxOp2yDINsaY= X-Forefront-Antispam-Report: CIP:204.77.163.244;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:edgetransport.garmin.com;PTR:extedge.garmin.com;CAT:NONE;SFS:(13230028)(376002)(136003)(346002)(39860400002)(396003)(451199021)(36840700001)(40470700004)(46966006)(26005)(36860700001)(107886003)(40480700001)(41300700001)(7696005)(83380400001)(336012)(426003)(186003)(47076005)(1076003)(2616005)(40460700003)(478600001)(82740400003)(4326008)(6916009)(82310400005)(7636003)(356005)(70206006)(70586007)(316002)(8676002)(8936002)(5660300002)(44832011)(2906002)(86362001)(36756003);DIR:OUT;SFP:1102; X-OriginatorOrg: garmin.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 13:17:38.8168 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a80fb935-330d-4cee-5d99-08db669066d4 X-MS-Exchange-CrossTenant-Id: 38d0d425-ba52-4c0a-a03e-2a65c8e82e2d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=38d0d425-ba52-4c0a-a03e-2a65c8e82e2d;Ip=[204.77.163.244];Helo=[edgetransport.garmin.com] X-MS-Exchange-CrossTenant-AuthSource: MW2NAM10FT059.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR04MB7770 X-Proofpoint-ORIG-GUID: B0uzEjaLsfKium1LcmtAMeWUQbKyzJoC X-Proofpoint-GUID: B0uzEjaLsfKium1LcmtAMeWUQbKyzJoC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_08,2023-06-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=999 clxscore=1011 phishscore=0 adultscore=0 spamscore=0 mlxscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060113 X-Original-Sender: nick.potenski@garmin.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@garmin.com header.s=pps1 header.b=G0dw1KBV; dkim=pass header.i=@garmin.com header.s=selector2 header.b=C42K9uTz; arc=pass (i=1 spf=pass spfdomain=garmin.com dmarc=pass fromdomain=garmin.com); spf=pass (google.com: domain of nick.potenski@garmin.com designates 205.220.165.212 as permitted sender) smtp.mailfrom=nick.potenski@garmin.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=garmin.com X-Original-From: Nick Potenski Reply-To: Nick Potenski 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 stream interface would not read all data from the socket due to two separate issues. This could cause swupdate to close the socket fd before a client has written all data, which results in an EPIPE on the client. First, stream_interface.c's extract_files() reset its offset variable before processing each file. This value is 4-byte aligned but not 512-byte aligned, so when it was used by cpio-utils.c's extract_padding() to compute the expected padding, it would produce an incorrect padding amount. Second, cpio-utils.c's extract_padding() could fail to read all padding in cases where the client uses a smaller chunk size, especially one less than the padding size, such as the swupdate-client reference implementation's 256 byte chunk size. Signed-off-by: Nick Potenski --- core/cpio_utils.c | 14 +++++++++++--- core/stream_interface.c | 1 - 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/cpio_utils.c b/core/cpio_utils.c index bcf4818..6408c8d 100644 --- a/core/cpio_utils.c +++ b/core/cpio_utils.c @@ -106,14 +106,22 @@ void extract_padding(int fd, unsigned long *offset) return; padding = (512 - (*offset % 512)) % 512; - if (padding) { - TRACE("Expecting %d padding bytes at end-of-file", padding); + if (!padding) + return; + + TRACE("Expecting %d padding bytes at end-of-file", padding); + do { len = read(fd, buf, padding); if (len < 0) { DEBUG("Failure while reading padding %d: %s", fd, strerror(errno)); return; } - } + padding -= len; + } while (len > 0); + + if (padding > 0) + DEBUG("Expected %d more bytes of padding", padding); + return; return; } diff --git a/core/stream_interface.c b/core/stream_interface.c index 34435fa..8c7a047 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -229,7 +229,6 @@ static int extract_files(int fd, struct swupdate_cfg *software) (skip == SKIP_FILE ? "Not required: skipping" : "required")); fdout = -1; - offset = 0; /* * If images are not streamed directly into the target