From nobody Thu May 2 01:55:46 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.zohomail.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 1505877853306459.33290668740665; Tue, 19 Sep 2017 20:24:13 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0E54B21E9460B; Tue, 19 Sep 2017 20:21:07 -0700 (PDT) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 86B4F21E3EA67 for ; Tue, 19 Sep 2017 20:21:05 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Sep 2017 20:24:09 -0700 Received: from sfu5-mobl.ccr.corp.intel.com ([10.239.193.42]) by orsmga004.jf.intel.com with ESMTP; 19 Sep 2017 20:24:00 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,420,1500966000"; d="scan'208";a="130527670" From: Fu Siyuan To: edk2-devel@lists.01.org Date: Wed, 20 Sep 2017 11:23:57 +0800 Message-Id: <20170920032357.5864-1-siyuan.fu@intel.com> X-Mailer: git-send-email 2.13.0.windows.1 Subject: [edk2] [Patch] MdeModulePkg/DxeNetLib: Check the actual packet size before trim data from Nbuf. 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 , Michael Turner , 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" In NetbufTrim() function, the NetBuf TotalSize should be checked with 0 bef= ore making the trim operation, otherwise the function will fall into infinite l= oop. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan Cc: Wu Jiaxin Cc: Ye Ting Cc: Michael Turner --- MdeModulePkg/Library/DxeNetLib/NetBuffer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c b/MdeModulePkg/Libr= ary/DxeNetLib/NetBuffer.c index 95cb71714b..25fc78e49e 100644 --- a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c +++ b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c @@ -1175,6 +1175,10 @@ NetbufTrim ( =20 NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE); =20 + if (Nbuf->TotalSize =3D=3D 0) { + return 0; + } + if (Len > Nbuf->TotalSize) { Len =3D Nbuf->TotalSize; } --=20 2.13.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel