From nobody Mon Apr 29 15:47:53 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1492079810017628.8564723494167; Thu, 13 Apr 2017 03:36:50 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E854E2063DE03; Thu, 13 Apr 2017 03:36:48 -0700 (PDT) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2D12121A04811 for ; Thu, 13 Apr 2017 03:36:47 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Apr 2017 03:36:46 -0700 Received: from zcui6-mobl.ccr.corp.intel.com (HELO JIAXINWU-MOBL2.ccr.corp.intel.com) ([10.255.27.187]) by fmsmga002.fm.intel.com with ESMTP; 13 Apr 2017 03:36:45 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,194,1488873600"; d="scan'208";a="1155316259" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Thu, 13 Apr 2017 18:36:42 +0800 Message-Id: <1492079802-180-1-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [edk2] [Patch] NetworkPkg/HttpDxe: Fix HTTP download OS image over 4G size failure X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Zhang Lubo , Fu Siyuan , Wu Jiaxin MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" UINT32 integer overflow will happen once the download OS image over 4G size. This patch is to fix this issue. Cc: Ye Ting Cc: Fu Siyuan Cc: Zhang Lubo Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin Reviewed-by: Fu Siyuan Reviewed-by: Sriram Subramanian Reviewed-by: Ye Ting =20 --- NetworkPkg/HttpDxe/HttpProto.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c index 3d61ba2..3fda294 100644 --- a/NetworkPkg/HttpDxe/HttpProto.c +++ b/NetworkPkg/HttpDxe/HttpProto.c @@ -2029,24 +2029,24 @@ HttpTcpReceiveBody ( ASSERT (Tcp4 !=3D NULL); } =20 if (HttpInstance->LocalAddressIsIPv6) { Rx6Token =3D &Wrap->TcpWrap.Rx6Token; - Rx6Token ->Packet.RxData->DataLength =3D (UINT32) HttpMsg->BodyLength; - Rx6Token ->Packet.RxData->FragmentTable[0].FragmentLength =3D (UINT32)= HttpMsg->BodyLength; + Rx6Token ->Packet.RxData->DataLength =3D (UINT32) MIN (MAX_UINT32, Htt= pMsg->BodyLength); + Rx6Token ->Packet.RxData->FragmentTable[0].FragmentLength =3D (UINT32)= MIN (MAX_UINT32, HttpMsg->BodyLength); Rx6Token ->Packet.RxData->FragmentTable[0].FragmentBuffer =3D (VOID *)= HttpMsg->Body; Rx6Token->CompletionToken.Status =3D EFI_NOT_READY; =20 Status =3D Tcp6->Receive (Tcp6, Rx6Token); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "Tcp6 receive failed: %r\n", Status)); return Status; } } else { Rx4Token =3D &Wrap->TcpWrap.Rx4Token; - Rx4Token->Packet.RxData->DataLength =3D (UINT32) HttpMsg->BodyLength; - Rx4Token->Packet.RxData->FragmentTable[0].FragmentLength =3D (UINT32) = HttpMsg->BodyLength; + Rx4Token->Packet.RxData->DataLength =3D (UINT32) MIN (MAX_UINT32, Http= Msg->BodyLength); + Rx4Token->Packet.RxData->FragmentTable[0].FragmentLength =3D (UINT32) = MIN (MAX_UINT32, HttpMsg->BodyLength); Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer =3D (VOID *) = HttpMsg->Body; =20 Rx4Token->CompletionToken.Status =3D EFI_NOT_READY; Status =3D Tcp4->Receive (Tcp4, Rx4Token); if (EFI_ERROR (Status)) { --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel