From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 B02C981F1B for ; Wed, 14 Dec 2016 23:42:04 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 14 Dec 2016 23:42:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,350,1477983600"; d="scan'208";a="798220627" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by FMSMGA003.fm.intel.com with ESMTP; 14 Dec 2016 23:42:03 -0800 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 14 Dec 2016 23:41:54 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 14 Dec 2016 23:41:53 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.11]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.77]) with mapi id 14.03.0248.002; Thu, 15 Dec 2016 15:41:50 +0800 From: "Ye, Ting" To: "Wu, Hao A" , "edk2-devel@lists.01.org" CC: "Fu, Siyuan" , "Wu, Jiaxin" Thread-Topic: [PATCH 4/6] MdeModulePkg/DxeNetLib: Rewrite NetblockChecksum function logic Thread-Index: AQHSVf0FaI06d1bk4EyM2V2qViCAt6EIoWLw Date: Thu, 15 Dec 2016 07:41:49 +0000 Message-ID: References: <1481714811-12568-1-git-send-email-hao.a.wu@intel.com> <1481714811-12568-5-git-send-email-hao.a.wu@intel.com> In-Reply-To: <1481714811-12568-5-git-send-email-hao.a.wu@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 4/6] MdeModulePkg/DxeNetLib: Rewrite NetblockChecksum function logic X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Dec 2016 07:42:04 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ye Ting -----Original Message----- From: Wu, Hao A=20 Sent: Wednesday, December 14, 2016 7:27 PM To: edk2-devel@lists.01.org Cc: Wu, Hao A ; Fu, Siyuan ; Ye, T= ing ; Wu, Jiaxin Subject: [PATCH 4/6] MdeModulePkg/DxeNetLib: Rewrite NetblockChecksum funct= ion logic This commit rewrites the logic for NetblockChecksum. It processes the check= sum of the left-over byte first to prevent possible mis-reports by static c= ode checkers. Cc: Fu Siyuan Cc: Ye Ting Cc: Wu Jiaxin Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu --- MdeModulePkg/Library/DxeNetLib/NetBuffer.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c b/MdeModulePkg/Libr= ary/DxeNetLib/NetBuffer.c index bbbdbc0..95cb717 100644 --- a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c +++ b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c @@ -1,7 +1,7 @@ /** @file Network library functions providing net buffer operation support. =20 -Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -1661,6 +1= 661,13 @@ NetblockChecksum ( =20 Sum =3D 0; =20 + // + // Add left-over byte, if any + // + if (Len % 2 !=3D 0) { + Sum +=3D *(Bulk + Len - 1); + } + while (Len > 1) { Sum +=3D *(UINT16 *) Bulk; Bulk +=3D 2; @@ -1668,13 +1675,6 @@ NetblockChecksum ( } =20 // - // Add left-over byte, if any - // - if (Len > 0) { - Sum +=3D *(UINT8 *) Bulk; - } - - // // Fold 32-bit sum to 16 bits // while ((Sum >> 16) !=3D 0) { -- 1.9.5.msysgit.0