From patchwork Fri Jul 21 17:00:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Potenski X-Patchwork-Id: 1811045 X-Patchwork-Delegate: sbabic@denx.de 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::c40; helo=mail-oo1-xc40.google.com; envelope-from=swupdate+bncbcdm5inazqbbbupt5ksqmgqeiep2gsi@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=hhia63RC; dkim-atps=neutral Received: from mail-oo1-xc40.google.com (mail-oo1-xc40.google.com [IPv6:2607:f8b0:4864:20::c40]) (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 4R6wn23hckz1yYc for ; Sat, 22 Jul 2023 03:01:08 +1000 (AEST) Received: by mail-oo1-xc40.google.com with SMTP id 006d021491bc7-5667dddaa5csf3634714eaf.2 for ; Fri, 21 Jul 2023 10:01:08 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1689958867; cv=pass; d=google.com; s=arc-20160816; b=w087EBhrviFuiTuugkiNpJez6cIIzXY4cnNYD1Cew3Ty/ICUkrhmdFYW3SQe1rmUoS DUQbrJdjW5/5okUsPPsHlldtcfKhSRpTNRMA4qNdm/aEHQqBnDdgmNpT9HVqNWXEjk1m /EBqZwQS6S0LOu00onaFWmWZen0X6lROnXlnrx4gfpeggO9YMxpmxipXuc2PhFr+n6b7 S23IGgnq9yj4OA4M4Qqt8wE2LkS0YtVxDQWNAnRqTTlw/7Fx4EkXQzFEBx61OI2fzyiM Ofb4ZNdvTJsfrxgbeIhVSK1kejFIBvon8RzSw925hkgcKHfBO79APW+ffaLu/NUuAxtW sKgA== 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=THK+LFOQKpAsKRtm6OvFAs/0v8xIxqUaZqSxxV+wF28=; fh=iOVGEoG+HiA07iGvxPqwK7rYuShtgW8d2GSvhq1gcrk=; b=cRYsIQeSNyRWEZ4m0y55PgrGJkW4LDFi1WbAsXJQT6vifPlcmymKlJutqJ37CcGlSG 6VqfM4Bmj8YJPeUKbmrOQYz5RH80llhHBYOmsD18zcpdAfJVpd1rXk5fclvjuFHEZySP JCwET4YbjaQc6nTDyx/kpKWi6Y6e3JpdStGILl9rXS7l0ZkAJpuf16epblzSuprU11ao M8avn7UNSRAtHshfh+jHynvJI16/4OZSMw4gk5ruy53rrps8jZHz3YpzgZa2VeYPd1/b XtG2vop9eEOVEJBu2RrvrAX3GWjuUomH9HN6EntyNN4R9a86qjglGcyJsixbs5n9ejht uhgg== ARC-Authentication-Results: i=3; gmr-mx.google.com; dkim=pass header.i=@garmin.com header.s=pps1 header.b=tbqlAB0F; dkim=pass header.i=@garmin.com header.s=selector2 header.b=cXAg4+qV; 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.177.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=1689958867; x=1690563667; 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=THK+LFOQKpAsKRtm6OvFAs/0v8xIxqUaZqSxxV+wF28=; b=hhia63RCHsQAYHkAdjAlT2dVkmbZaap/M1SncVZmONsmlLr7IwaM2iFQ6CzzbB0gZB 2AdJYojZjrTuxk++iYHhNgRXrcBDfJ8/IJochcd1lylfmjALTHAxrQJ/H1t8+uKV9AHH LjFQquigxF7KIMKAhuNOVwOwA2Q0IhLWWjNFMU8MyyXS6nRicFuYxQQ+QW5YMr+oVvwf AOp1ALJrOb2V8iXUTdUWVVK4LGijZ9fHA0Vb/teNwKB/C6iGkj7dPxrW30MW0awlG72b OjQNEf+ZzlsATCi4jFSpEgxw2TiXCSjDAseSKpWqYq+1tRucDfSTMu/0iszgnQ0V9/PH aaXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689958867; x=1690563667; 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=THK+LFOQKpAsKRtm6OvFAs/0v8xIxqUaZqSxxV+wF28=; b=DwEz6+b/DhfBYd661k4CawxUrVhW27Bo5h2BBQBZ7ge25rrnTSlxzTpYkir3q89UMi TFnX7U/aAQNXKH6JIbuktI2lWBm6o+Ge9O1b67ie3yV6i2AVGFuIawBGVV3+dcgR7+XA w0hfpMTKmIs0ADH3AOwXr9XSfCUuofSbHjLXFcQj9EIctDRTCvhyGJpuUEBvAAg9HLTr kadKT3HXExXV0dvbKu0pLpSJNrXb7+bFcETpm5bxB73j6MwRetakOKTId7UnGJYVk9Df WY1VKPojR/LPkU1nz3/ETxVyF6kqTHzPpg/I7MUQkIFGM4+AQdTYyfna4GqsKGd8rX0/ WbtA== X-Gm-Message-State: ABy/qLaRTX6wmRRBTloG9D4/o4CR4Arfo6zWWCUGpMp23eWcLs3Fswpf A5blMSM2ji/pPGHIh39N13o= X-Google-Smtp-Source: APBJJlG7k9VBvMf40eRwC5fx07aaSh6ECYaGVbVZ7lYNA1kvBbfVWDkrzFqTJ8642h3YtBDkhHwh/Q== X-Received: by 2002:a05:6870:5686:b0:1b3:ef56:270a with SMTP id p6-20020a056870568600b001b3ef56270amr2553223oao.29.1689958866467; Fri, 21 Jul 2023 10:01:06 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6871:5207:b0:1b0:6565:5439 with SMTP id ht7-20020a056871520700b001b065655439ls2595385oac.2.-pod-prod-06-us; Fri, 21 Jul 2023 10:01:05 -0700 (PDT) X-Received: by 2002:a05:6808:de0:b0:3a3:bf6e:5a4f with SMTP id g32-20020a0568080de000b003a3bf6e5a4fmr2581550oic.43.1689958865419; Fri, 21 Jul 2023 10:01:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1689958865; cv=pass; d=google.com; s=arc-20160816; b=Nhvch/fCUh3b2ajdVh7nfQg7M/UHmovYJ69eZrXzpYMkL5Z71HsehR+GBr7oHzf+3u XK6HtIzWPyorz8T/0FdA66N15AV5Ty1+g/gNd/RkDYIs1pfBaikJT0GD9pfHmKD3fntD P3EkgNQSg4tFMd0J2BTN9/UIAPMMMUGrlkZJQAVx57P7OjNm7Ue1G7Huaj/nNSJyjgFi eNyuTt3IYn3y0+xIawIxv9vbP0wi1zm9Uf0uqjck9d2ZHY1e3mZrMl3s5Whe/Fd9eS64 0VfyUNxrNz2fNxyTERmzBfTYO3phD4y2Qfl27ZEjRFyiWxFPokmwQzjTZ7E3+9UTt/yE iGsA== 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=T4tr0LxYXFWWHaCBovYYEbUpSKWiac5sts5PRnYOzsY=; fh=XAD2wieYk+pKe9srK/r15Vf64g84Ti1UMWCCyInuRaE=; b=MPqep4n8WPoVCU/HNTIrOz6zspt6gYzWLiSz/Pf1pP0u23tA2wNXHFsxMmCUDBf7/w DH6SB/64L5s60IdC465BBObSE4cXl9scqRpncZqGk9u/bl12lCC/le+bKnrsiLWil5Pn aihNwTIMou03OyW0HryIS/JZ1UIO4at/c+FOKxQ9SlqRHc0LtE5uGoyCX0uGzaEX5gLY 5J3F784ZpDtIvRQuXTvJMSbVyFvRKtuclpX7zyPsMDG0FNRVPFGXFGFs5IQNgOPDihKE fJRYdzbexo5KFqrundcZcWabBYfkC9TCzJdmXh9VdVmAiIgfL8mEQ5swKZqjaFrnIUS3 myKA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@garmin.com header.s=pps1 header.b=tbqlAB0F; dkim=pass header.i=@garmin.com header.s=selector2 header.b=cXAg4+qV; 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.177.212 as permitted sender) smtp.mailfrom=nick.potenski@garmin.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=garmin.com Received: from mx0b-000eb902.pphosted.com (mx0b-000eb902.pphosted.com. [205.220.177.212]) by gmr-mx.google.com with ESMTPS id m2-20020ad44d42000000b00630039463bcsi294957qvm.6.2023.07.21.10.01.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Jul 2023 10:01:05 -0700 (PDT) Received-SPF: pass (google.com: domain of nick.potenski@garmin.com designates 205.220.177.212 as permitted sender) client-ip=205.220.177.212; Received: from pps.filterd (m0220299.ppops.net [127.0.0.1]) by mx0a-000eb902.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36LGCsbb008025 for ; Fri, 21 Jul 2023 12:01:05 -0500 Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by mx0a-000eb902.pphosted.com (PPS) with ESMTPS id 3rxgu24ak4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 21 Jul 2023 12:01:04 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KUwcUw6ySrYiXmOa/a8al5CNUeWPngQbXqSu0A9KQmgdiwWr4Jy+N1PZBxPjHGiAIGoWXo0Yvpn1dGW1tTqhgPkMLg2N++fYvztX+iXA3wl9u1CtGb84nrXNPzYgyyYFd7g7/hYpb72n0M0kDizPK4mRrDwntBAESvCX6ymIYO3/kg44f7j+AgAY3SXMOoegbCe3CPxFTgXwPG56jxlrLvAbZoLXkUNA28vWEbdlfEWNGVuw0+gtJGu9XIPD3TNHGio/60DyMQtSz/TgwBB/cHPcAq2f7V6U9c5HGLaQf8iprwdIfJgCywg9935rTdj4eK7UODYjcpYu0z9Xa1V8bw== 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=T4tr0LxYXFWWHaCBovYYEbUpSKWiac5sts5PRnYOzsY=; b=RPSmtDWHbGGvwanj4JFFCPDU5qBYMB6GOkSwKczhQh8+PJ/P0s2kiP3805j5HELrxuWJGRhPod4U5Y7HUQ31iuC2H8oAS5/KCyusucLlgJE53meMtdSb3UHkcn/6Un/bJSqvmrUFhnb+Tg9M6EeXVBHZp5xrmEjHncgWTbDDDIFBIZYO6KCaWSaEx5wos//l72jB09WeumtSBFHJIl3lW4syiEwuOvQv4BjmOFwiDWNCeZzIBbHXr6gVAefIChLCoJsXBzePfeMvM43sXCEHUpQr29q0a5xRUA6Pau8f+x9h1Xt2Oz9rkfJc/q9WQWv1wWbXhW+DzuCo9Xb3clrHvw== 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 MW4PR03CA0240.namprd03.prod.outlook.com (2603:10b6:303:b9::35) by SA1PR04MB8917.namprd04.prod.outlook.com (2603:10b6:806:375::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.28; Fri, 21 Jul 2023 17:01:01 +0000 Received: from MW2NAM10FT021.eop-nam10.prod.protection.outlook.com (2603:10b6:303:b9:cafe::2a) by MW4PR03CA0240.outlook.office365.com (2603:10b6:303:b9::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.25 via Frontend Transport; Fri, 21 Jul 2023 17:01:00 +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 MW2NAM10FT021.mail.protection.outlook.com (10.13.155.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.28 via Frontend Transport; Fri, 21 Jul 2023 17:01:00 +0000 Received: from cv1wpa-exmb3.ad.garmin.com (10.5.144.73) by olawpa-edge3.garmin.com (10.60.4.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.6; Fri, 21 Jul 2023 12:00:54 -0500 Received: from kc3wpa-exmb3.ad.garmin.com (10.65.32.83) by cv1wpa-exmb3.ad.garmin.com (10.5.144.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.34; Fri, 21 Jul 2023 12:00:59 -0500 Received: from kc3wpa-exmb4.ad.garmin.com (10.65.32.84) by kc3wpa-exmb3.ad.garmin.com (10.65.32.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Fri, 21 Jul 2023 12:00:59 -0500 Received: from OLA-J986JV2.ad.garmin.com (10.5.209.17) by mail.garmin.com (10.65.32.84) with Microsoft SMTP Server id 15.2.1118.30 via Frontend Transport; Fri, 21 Jul 2023 12:00:59 -0500 X-Patchwork-Original-From: "'Nick Potenski' via swupdate" From: Nick Potenski To: CC: Nick Potenski Subject: [swupdate] [PATCH v4] Fix calculation and reading of end-of-file padding Date: Fri, 21 Jul 2023 12:00:11 -0500 Message-ID: <20230721170042.104986-1-nick.potenski@garmin.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW2NAM10FT021:EE_|SA1PR04MB8917:EE_ X-MS-Office365-Filtering-Correlation-Id: 22394604-cbb2-4dc4-9733-08db8a0c0f81 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5Cs7YSc+A+lRnwzBaGHPMWS70QSmVH/BOnQfVPgwcguEE1TtewTfJWNrzqtXMgSTvYuQAUX/bDkPWGFgCmtPPRlotLBYmF8GCexhIHnsuYTLvl54OeDm1Ed+jOnldFany3wxP7mowFz6x4ENh25p7eK76U7f4LUQbgMTIY/4ExLxzBsOVGyAk0qj1E0PD59nT4Xg5zpr/hJPriPN9IRScds4fvc5eE9A68cwo6cpF9U4ynU5QtoHDMEfjSrHD2vxX75V5W6j9AwprzOQPHCo9KX/P06KgoDZ28nSAchJ9ulUmGrLVVwD5cQpx+SSOAnkTcqLZPdz2PU1s3jfveu/G+2R/T2Nf/g3Dx6VUCcM+ZEdpLq5W7taAnOPg9lAs9RboulOv3LzaNwX7A4diGOEGcM3BULHXYoQigivLzKk8oDrkLdJ61BaJXxJGbzTHXRSCrCSfDjwwCWcVlrq5+bvRjBFb38tfMuUwtCuU9TejZwfcNFA1gVRIbin4SlJmin+3CqLYuSOkuyiYAxpeuG0E1XB99NJ7HqTMBU4EJJdwWttuMfSHnOPo0FFq5IIFbdr3vT35u9b18rI5ajtEPKCsRITDEWT9F0MmOMdfGRI+CidWv4xKCkdFtrOJW97/Afltpp2nfmQWSi1gRC0xvepApWDbTCHrUYzLsxIsXSuVKatFsrViuYlOD0XqDgcIpnau7PLsv3PHpDmVBLWtoM6UmhCXoxBkcBHHYQQ8YO8Nkasxt7szew0rfErszOLsx8H 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)(396003)(346002)(39860400002)(136003)(451199021)(82310400008)(40470700004)(36840700001)(46966006)(316002)(40460700003)(70206006)(70586007)(6916009)(4326008)(7636003)(356005)(6666004)(7696005)(40480700001)(86362001)(44832011)(478600001)(2906002)(82740400003)(36756003)(426003)(41300700001)(47076005)(2616005)(107886003)(5660300002)(8936002)(8676002)(186003)(336012)(1076003)(26005)(83380400001)(36860700001);DIR:OUT;SFP:1102; X-OriginatorOrg: garmin.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2023 17:01:00.6198 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 22394604-cbb2-4dc4-9733-08db8a0c0f81 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: MW2NAM10FT021.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR04MB8917 X-Proofpoint-GUID: frwP49mAJqzStiJNFwoaIFkK_8EYEXI8 X-Proofpoint-ORIG-GUID: frwP49mAJqzStiJNFwoaIFkK_8EYEXI8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-21_10,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 suspectscore=0 spamscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307210147 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=tbqlAB0F; dkim=pass header.i=@garmin.com header.s=selector2 header.b=cXAg4+qV; 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.177.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 may not read all data from the socket which could cause swupdate to close the socket fd before a client has written all data, resulting in an EPIPE on the client. Instead of trying to calculate and expect a specific number of padding bytes, perform best effort to read up to 512 bytes or until an error or timeout is encountered. Signed-off-by: Nick Potenski --- core/cpio_utils.c | 37 +++++++++++++++++++++++++++++++------ core/stream_interface.c | 2 +- include/cpiohdr.h | 2 +- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/core/cpio_utils.c b/core/cpio_utils.c index bcf4818..024973e 100644 --- a/core/cpio_utils.c +++ b/core/cpio_utils.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #ifdef CONFIG_GUNZIP #include #endif @@ -96,25 +98,48 @@ static int fill_buffer(int fd, unsigned char *buf, unsigned int nbytes, unsigned * Read padding that could exists between the cpio trailer and the end-of-file. * cpio aligns the file to 512 bytes */ -void extract_padding(int fd, unsigned long *offset) +void extract_padding(int fd) { int padding; ssize_t len; unsigned char buf[512]; + int old_flags; + struct pollfd pfd; + int retval; - if (fd < 0 || !offset) + if (fd < 0) return; - padding = (512 - (*offset % 512)) % 512; - if (padding) { - TRACE("Expecting %d padding bytes at end-of-file", padding); + old_flags = fcntl(fd, F_GETFL); + if (old_flags < 0) + return; + + if (fcntl(fd, F_SETFL, old_flags | O_NONBLOCK) < 0) + return; + + pfd.fd = fd; + pfd.events = POLLIN; + + padding = 512; + + TRACE("Expecting up to 512 padding bytes at end-of-file"); + do { + retval = poll(&pfd, 1, 1000); + if (retval < 0) { + DEBUG("Failure while waiting on fd %d: %s", fd, strerror(errno)); + (void)fcntl(fd, F_SETFL, old_flags); + return; + } len = read(fd, buf, padding); if (len < 0) { DEBUG("Failure while reading padding %d: %s", fd, strerror(errno)); + (void)fcntl(fd, F_SETFL, old_flags); return; } - } + padding -= len; + } while (len > 0 && padding > 0); + (void)fcntl(fd, F_SETFL, old_flags); return; } diff --git a/core/stream_interface.c b/core/stream_interface.c index 34435fa..3f0b952 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -205,7 +205,7 @@ static int extract_files(int fd, struct swupdate_cfg *software) * to 512 bytes from the socket until the * client stops writing */ - extract_padding(fd, &offset); + extract_padding(fd); status = STREAM_END; break; } diff --git a/include/cpiohdr.h b/include/cpiohdr.h index d263776..0be844a 100644 --- a/include/cpiohdr.h +++ b/include/cpiohdr.h @@ -59,7 +59,7 @@ struct filehdr { int get_cpiohdr(unsigned char *buf, struct filehdr *fhdr); 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, unsigned long *offset); +void extract_padding(int fd); bool swupdate_verify_chksum(const uint32_t chk1, struct filehdr *fhdr); #endif