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.65; helo=mga03.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 A6C3F211B76B1 for ; Mon, 28 Jan 2019 21:10:03 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jan 2019 21:10:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,536,1539673200"; d="scan'208";a="315703181" Received: from jwang36-mobl2.ccr.corp.intel.com ([10.249.175.118]) by fmsmga005.fm.intel.com with ESMTP; 28 Jan 2019 21:10:02 -0800 From: Jian J Wang To: edk2-devel@lists.01.org Cc: Liming Gao , Ray Ni , Michael D Kinney Date: Tue, 29 Jan 2019 13:09:58 +0800 Message-Id: <20190129050959.11692-2-jian.j.wang@intel.com> X-Mailer: git-send-email 2.19.0.windows.1 In-Reply-To: <20190129050959.11692-1-jian.j.wang@intel.com> References: <20190129050959.11692-1-jian.j.wang@intel.com> MIME-Version: 1.0 Subject: [PATCH 1/2] MdePkg/UefiDevicePathLib: Add sanity check for FilePath device path 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, 29 Jan 2019 05:10:03 -0000 Content-Transfer-Encoding: 8bit REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1497 Current implementation of IsDevicePathValid() is not enough for type of MEDIA_FILEPATH_DP, which has NULL-terminated string in the device path. This patch add a simple NULL character check at Length position. Cc: Liming Gao Cc: Ray Ni Cc: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang --- MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c index 665e5a4adc..6d87744510 100644 --- a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c @@ -96,6 +96,14 @@ IsDevicePathValid ( return FALSE; } } + + // + // FilePath must be a NULL-terminated string. + // + if (DevicePathType (DevicePath) == MEDIA_FILEPATH_DP && + *(CHAR16 *)((UINT8 *)DevicePath + NodeLength - 2) != 0) { + return FALSE; + } } // -- 2.19.0.windows.1