X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=NetworkPkg%2FApplication%2FIpsecConfig%2FPolicyEntryOperation.c;h=9bbc11490c5430cfb883c9c444b99e6414235a59;hp=67209f6247f660df39d952266d251d95413ca06c;hb=a51896e475cd62e742d54f1a0addd699237a24c2;hpb=da7c529ca1c93071792745005aea5edf38669731 diff --git a/NetworkPkg/Application/IpsecConfig/PolicyEntryOperation.c b/NetworkPkg/Application/IpsecConfig/PolicyEntryOperation.c index 67209f6247..9bbc11490c 100644 --- a/NetworkPkg/Application/IpsecConfig/PolicyEntryOperation.c +++ b/NetworkPkg/Application/IpsecConfig/PolicyEntryOperation.c @@ -1,7 +1,7 @@ /** @file The implementation of policy entry operation function in IpSecConfig application. - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -784,6 +784,7 @@ CreateSadEntry ( if (ValueStr != NULL ) { (*Data)->AlgoInfo.EspAlgoInfo.EncKeyLength = EncKeyLength; AsciiStr = AllocateZeroPool (EncKeyLength + 1); + ASSERT (AsciiStr != NULL); UnicodeStrToAsciiStr (ValueStr, AsciiStr); CopyMem ((*Data)->AlgoInfo.EspAlgoInfo.EncKey, AsciiStr, EncKeyLength); FreePool (AsciiStr); @@ -813,6 +814,7 @@ CreateSadEntry ( if (ValueStr != NULL) { (*Data)->AlgoInfo.EspAlgoInfo.AuthKeyLength = AuthKeyLength; AsciiStr = AllocateZeroPool (AuthKeyLength + 1); + ASSERT (AsciiStr != NULL); UnicodeStrToAsciiStr (ValueStr, AsciiStr); CopyMem ((*Data)->AlgoInfo.EspAlgoInfo.AuthKey, AsciiStr, AuthKeyLength); FreePool (AsciiStr); @@ -1102,7 +1104,7 @@ CreatePadEntry ( ValueStr = ShellCommandLineGetValue (ParamPackage, L"--peer-id"); if (ValueStr != NULL) { (*PadId)->PeerIdValid = TRUE; - StrnCpy ((CHAR16 *) (*PadId)->Id.PeerId, ValueStr, ARRAY_SIZE ((*PadId)->Id.PeerId) - 1); + StrnCpyS ((CHAR16 *) (*PadId)->Id.PeerId, MAX_PEERID_LEN / sizeof (CHAR16), ValueStr, MAX_PEERID_LEN / sizeof (CHAR16) - 1); *Mask |= PEER_ID; } @@ -1396,8 +1398,10 @@ CombineSpdEntry ( // // Process Data // + OldData->SaIdCount = 0; + if ((Mask & NAME) != 0) { - AsciiStrCpy ((CHAR8 *) OldData->Name, (CHAR8 *) NewData->Name); + AsciiStrCpyS ((CHAR8 *) OldData->Name, MAX_PEERID_LEN, (CHAR8 *) NewData->Name); } if ((Mask & PACKET_FLAG) != 0) { @@ -1860,37 +1864,30 @@ EditOperatePolicyEntry ( &CreateNew ); if (!EFI_ERROR (Status)) { + // + // If the Selector already existed, this Entry will be updated by set data. + // + Status = mIpSecConfig->SetData ( + mIpSecConfig, + Context->DataType, + Context->Selector, /// New created selector. + Data, /// Old date which has been modified, need to be set data. + Selector + ); + ASSERT_EFI_ERROR (Status); + if (CreateNew) { // - // Insert new entry before old entry + // Edit the entry to a new one. So, we need delete the old entry. // Status = mIpSecConfig->SetData ( mIpSecConfig, Context->DataType, - Context->Selector, - Data, - Selector - ); - ASSERT_EFI_ERROR (Status); - // - // Delete old entry - // - Status = mIpSecConfig->SetData ( - mIpSecConfig, - Context->DataType, - Selector, - NULL, + Selector, /// Old selector. + NULL, /// NULL means to delete this Entry specified by Selector. NULL ); ASSERT_EFI_ERROR (Status); - } else { - Status = mIpSecConfig->SetData ( - mIpSecConfig, - Context->DataType, - Context->Selector, - Data, - NULL - ); } }