From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 8E885802B6 for ; Thu, 23 Mar 2017 23:44:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490337855; x=1521873855; h=from:to:cc:subject:date:message-id; bh=yoiUp0DuX0mKkn3A1OSYZCSnSofbpaDZwLZEtyv/VZs=; b=N1/zxRWSjXwVhJIDZhW+K02a4tAliSXvZtbpQL/vJ0AoUQ8Vb3vaiFMH swHNKf3dbtWo6F894IOfPP24zy4sJQ==; Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Mar 2017 23:44:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,213,1486454400"; d="scan'208";a="947715959" Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.108]) by orsmga003.jf.intel.com with ESMTP; 23 Mar 2017 23:44:13 -0700 From: Jiaxin Wu To: edk2-devel@lists.01.org Cc: Warner Losh , Liming Gao , Ye Ting , Fu Siyuan , Wu Jiaxin Date: Fri, 24 Mar 2017 14:44:12 +0800 Message-Id: <1490337852-7104-1-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [Patch] MdePkg/UefiDevicePathLib: Refine the DevPathFromTextiSCSI protocol parsing 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: , X-List-Received-Date: Fri, 24 Mar 2017 06:44:15 -0000 For current iSCSI protocol parsing, UINT16 truncation may be happened. Since the Spec already have declaimed that 0 is TCP Protocol and 1+ is reserved, the parsing can be refined as below: if (StrCmp (ProtocolStr, L"TCP") == 0) { ISCSIDevPath->NetworkProtocol = 0; } else { // // Undefined and reserved. // ISCSIDevPath->NetworkProtocol = 1; } Cc: Warner Losh Cc: Liming Gao Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c index 3c9df28..4322b6c 100644 --- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c @@ -2579,11 +2579,18 @@ DevPathFromTextiSCSI ( Options |= 0x1000; } ISCSIDevPath->LoginOption = (UINT16) Options; - ISCSIDevPath->NetworkProtocol = (UINT16) StrCmp (ProtocolStr, L"TCP"); + if (StrCmp (ProtocolStr, L"TCP") == 0) { + ISCSIDevPath->NetworkProtocol = 0; + } else { + // + // Undefined and reserved. + // + ISCSIDevPath->NetworkProtocol = 1; + } return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath; } /** -- 1.9.5.msysgit.1