From: Zhang, Lubo Date: Thu, 9 Mar 2017 08:17:56 +0000 (+0800) Subject: NetworkPkg: Fix potential bug if the iSCSI use dns protocol. X-Git-Tag: edk2-stable201903~4398 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=df077b3e07098f252a061d3e0a926f6696d24936 NetworkPkg: Fix potential bug if the iSCSI use dns protocol. Since we use the Attempt and index as the attempt variable name instead of the MAC address plus index, we need to update this to check the whether the Controller handle is configured to use DNS protocol Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo Cc: Ye Ting Cc: Fu Siyuan Cc: Wu Jiaxin Reviewed-by: Wu Jiaxin --- diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c index 7b4044fe5a..2c93590deb 100644 --- a/NetworkPkg/IScsiDxe/IScsiMisc.c +++ b/NetworkPkg/IScsiDxe/IScsiMisc.c @@ -1778,7 +1778,7 @@ IScsiDhcpIsConfigured ( } /** - Check wheather the Controller handle is configured to use DNS protocol. + Check whether the Controller handle is configured to use DNS protocol. @param[in] Controller The handle of the controller. @@ -1799,6 +1799,7 @@ IScsiDnsIsConfigured ( EFI_MAC_ADDRESS MacAddr; UINTN HwAddressSize; UINT16 VlanId; + CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN]; CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; CHAR16 AttemptName[ISCSI_NAME_IFR_MAX_SIZE]; @@ -1828,10 +1829,10 @@ IScsiDnsIsConfigured ( UnicodeSPrint ( AttemptName, (UINTN) 128, - L"%s%d", - MacString, + L"Attempt %d", (UINTN) AttemptConfigOrder[Index] ); + Status = GetVariable2 ( AttemptName, &gEfiIScsiInitiatorNameProtocolGuid, @@ -1844,7 +1845,9 @@ IScsiDnsIsConfigured ( ASSERT (AttemptConfigOrder[Index] == AttemptTmp->AttemptConfigIndex); - if (AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED) { + AsciiStrToUnicodeStrS (AttemptTmp->MacString, AttemptMacString, sizeof (AttemptMacString) / sizeof (AttemptMacString[0])); + + if (AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED || StrCmp (MacString, AttemptMacString)) { FreePool (AttemptTmp); continue; }