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 C761121196206 for ; Mon, 10 Dec 2018 22:30:47 -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:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,341,1539673200"; d="scan'208";a="126845721" Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by fmsmga004.fm.intel.com with ESMTP; 10 Dec 2018 22:30:44 -0800 From: Shenglei Zhang To: edk2-devel@lists.01.org Cc: Bob Feng , Liming Gao Date: Tue, 11 Dec 2018 14:30:40 +0800 Message-Id: <20181211063041.25108-2-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 1/2] BaseTools/DevicePath: 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: Bob Feng Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Shenglei Zhang --- BaseTools/Source/C/DevicePath/DevicePathUtilities.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/BaseTools/Source/C/DevicePath/DevicePathUtilities.c b/BaseTools/Source/C/DevicePath/DevicePathUtilities.c index f8a41ff97d..e2efaeebf0 100644 --- a/BaseTools/Source/C/DevicePath/DevicePathUtilities.c +++ b/BaseTools/Source/C/DevicePath/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