From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.126; helo=mga18.intel.com; envelope-from=shenglei.zhang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 997EF2119175F for ; Mon, 10 Dec 2018 22:30:48 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Dec 2018 22:30:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,341,1539673200"; d="scan'208";a="126845729" Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by fmsmga004.fm.intel.com with ESMTP; 10 Dec 2018 22:30:46 -0800 From: Shenglei Zhang To: edk2-devel@lists.01.org Cc: Liming Gao , Michael D Kinney Date: Tue, 11 Dec 2018 14:30:41 +0800 Message-Id: <20181211063041.25108-3-shenglei.zhang@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 In-Reply-To: <20181211063041.25108-1-shenglei.zhang@intel.com> References: <20181211063041.25108-1-shenglei.zhang@intel.com> Subject: [PATCH 2/2] MdePkg/UefiDevicePathLib: Add a checking step X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Dec 2018 06:30:48 -0000 Add a checking step in DevicePathUtilities.c to verify DevicePath. Cc: Liming Gao Cc: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Shenglei Zhang --- .../Library/UefiDevicePathLib/DevicePathUtilities.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c index 665e5a4adc..f29e1e22f6 100644 --- a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c @@ -59,6 +59,18 @@ IsDevicePathValid ( UINTN Size; UINTN NodeLength; +/** + NULL device path is also invalid path. + + IsDevicePathValid() should return FALSE or TRUE, and not ASSERT(). + + This change needs to update IsDevicePathValid() API definition and implementation both. + +**/ + if (DevicePath == NULL || (MaxSize > 0 && MaxSize < END_DEVICE_PATH_LENGTH)) { + return FALSE; + } + ASSERT (DevicePath != NULL); if (MaxSize == 0) { -- 2.18.0.windows.1