From nobody Fri May 3 13:44:12 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1490757767025133.8896912630064; Tue, 28 Mar 2017 20:22:47 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C4B4D20D2C3B9; Tue, 28 Mar 2017 20:22:44 -0700 (PDT) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 CEE9C21DFA91C for ; Tue, 28 Mar 2017 20:22:42 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2017 20:22:42 -0700 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by orsmga004.jf.intel.com with ESMTP; 28 Mar 2017 20:22:41 -0700 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490757762; x=1522293762; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=c7Le1EFDZA2t9fNd2N/DtqtyJSG4xDR9z+s0odb7jFI=; b=BG9nhrh+LkR8S02yhPyQqNuCGo4b4ZJypOJ/BdTbXKQW1BS4N9HGh1SJ VJNVn1QJCdiczAyvLjheg3lDIKfxYQ==; X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,239,1486454400"; d="scan'208";a="71470862" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Wed, 29 Mar 2017 11:22:38 +0800 Message-Id: <20170329032238.255628-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 MIME-Version: 1.0 Subject: [edk2] [PATCH] ShellPkg/setvar: Support data format in Shell 2.2 spec 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: , Cc: Michael D Kinney , Jaben Carsey , Chen A Chen , Jeff Fan Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 From: Chen A Chen Shell 2.2 spec defines =3D0x/=3D0X, =3DH/=3Dh, =3DS, =3DL and =3DP for hex number, hex array, ascii string, unicode string and device path data. The patch adds such support. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chen A Chen Cc: Ruiyu Ni Cc: Michael D Kinney Cc: Jaben Carsey Cc: Jeff Fan --- .../Library/UefiShellDebug1CommandsLib/SetVar.c | 423 +++++++++++++++--= ---- 1 file changed, 297 insertions(+), 126 deletions(-) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c b/ShellPk= g/Library/UefiShellDebug1CommandsLib/SetVar.c index c59032a..fc76b58 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c @@ -1,4 +1,4 @@ -/** @file +=EF=BB=BF/** @file Main file for SetVar shell Debug1 function. =20 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
@@ -23,6 +23,21 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] =3D { {NULL, TypeMax} }; =20 +typedef enum { + DataTypeHexNumber =3D 0, + DataTypeHexArray =3D 1, + DataTypeAscii =3D 2, + DataTypeUnicode =3D 3, + DataTypeDevicePath =3D 4, + DataTypeUnKnow =3D 5 +} DATA_TYPE; + +typedef union { + UINT8 HexNumber8; + UINT16 HexNumber16; + UINT32 HexNumber32; + UINT64 HexNumber64; +} HEX_NUMBER; =20 /** Check if the input is a (potentially empty) string of hexadecimal nibble= s. @@ -50,6 +65,270 @@ IsStringOfHexNibbles ( return TRUE; } =20 +/** + Function to check the TYPE of Data. + + @param[in] Data The Data to be check. + + @retval DATA_TYPE The TYPE of Data. +**/ +DATA_TYPE +TestDataType ( + IN CONST CHAR16 *Data + ) +{ + if (Data[0] =3D=3D L'0' && (Data[1] =3D=3D L'x' || Data[1] =3D=3D L'X'))= { + if (IsStringOfHexNibbles (Data+2) && StrLen (Data + 2) <=3D 16) { + return DataTypeHexNumber; + } else { + return DataTypeUnKnow; + } + } else if (Data[0] =3D=3D L'H') { + if (IsStringOfHexNibbles (Data + 1) && StrLen (Data + 1) % 2 =3D=3D 0)= { + return DataTypeHexArray; + } else { + return DataTypeUnKnow; + } + } else if (Data[0] =3D=3D L'S') { + return DataTypeAscii; + } else if (Data[0] =3D=3D L'L') { + return DataTypeUnicode; + } else if (Data[0] =3D=3D L'P' || StrnCmp (Data, L"--", 2) =3D=3D 0) { + return DataTypeDevicePath; + } + + if (IsStringOfHexNibbles (Data) && StrLen (Data) % 2 =3D=3D 0) { + return DataTypeHexArray; + } + + return DataTypeAscii; +} + +/** + Function to parse the Data by the type of Data, and save in the Buffer. + + @param[in] Data A pointer to a buffer to be parsed. + @param[out] Buffer A pointer to a buffer to hold the re= turn data. + @param[in,out] BufferSize On input, indicates the size of Buff= er in bytes. + On output,indicates the size of data= return in Buffer. + Or the size in bytes of the buffer n= eeded to obtain. + + @retval EFI_INVALID_PARAMETER The Buffer or BufferSize is NULL. + @retval EFI_BUFFER_TOO_SMALL The Buffer is too small to hold the = data. + @retval EFI_OUT_OF_RESOURCES A memory allcation failed. + @retval EFI_SUCCESS The Data parsed successful and save = in the Buffer. +**/ +EFI_STATUS +ParseParameterData ( + IN CONST CHAR16 *Data, + OUT VOID *Buffer, + IN OUT UINTN *BufferSize + ) +{ + UINT64 HexNumber; + UINTN HexNumberLen; + UINTN Size; + CHAR8 *AsciiBuffer; + DATA_TYPE DataType; + EFI_DEVICE_PATH_PROTOCOL *DevPath; + EFI_STATUS Status; + + HexNumber =3D 0; + HexNumberLen =3D 0; + Size =3D 0; + AsciiBuffer =3D NULL; + DevPath =3D NULL; + Status =3D EFI_SUCCESS; + + if (Data =3D=3D NULL || BufferSize =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + DataType =3D TestDataType (Data); + if (DataType =3D=3D DataTypeHexNumber) { + // + // hex number + // + StrHexToUint64S (Data + 2, NULL, &HexNumber); + HexNumberLen =3D StrLen (Data + 2); + if (HexNumberLen >=3D 1 && HexNumberLen <=3D 2) { + Size =3D 1; + } else if (HexNumberLen >=3D 3 && HexNumberLen <=3D 4) { + Size =3D 2; + } else if (HexNumberLen >=3D 5 && HexNumberLen <=3D 8) { + Size =3D 4; + } else if (HexNumberLen >=3D 9 && HexNumberLen <=3D 16) { + Size =3D 8; + } + if (Buffer !=3D NULL && *BufferSize >=3D Size) { + CopyMem(Buffer, (VOID *)&HexNumber, Size); + } else { + Status =3D EFI_BUFFER_TOO_SMALL; + } + *BufferSize =3D Size; + } else if (DataType =3D=3D DataTypeHexArray) { + // + // hex array + // + if (*Data =3D=3D L'H') { + Data =3D Data + 1; + } + + Size =3D StrLen (Data) / 2; + if (Buffer !=3D NULL && *BufferSize >=3D Size) { + StrHexToBytes(Data, StrLen (Data), (UINT8 *)Buffer, Size); + } else { + Status =3D EFI_BUFFER_TOO_SMALL; + } + *BufferSize =3D Size; + } else if (DataType =3D=3D DataTypeAscii) { + // + // ascii text + // + if (*Data =3D=3D L'S') { + Data =3D Data + 1; + } + AsciiBuffer =3D AllocateZeroPool (StrSize (Data) / 2); + if (AsciiBuffer =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + } else { + AsciiSPrint (AsciiBuffer, StrSize (Data) / 2, "%s", (CHAR8 *)Data); + + Size =3D StrSize (Data) / 2 - 1; + if (Buffer !=3D NULL && *BufferSize >=3D Size) { + CopyMem (Buffer, AsciiBuffer, Size); + } else { + Status =3D EFI_BUFFER_TOO_SMALL; + } + *BufferSize =3D Size; + } + SHELL_FREE_NON_NULL (AsciiBuffer); + } else if (DataType =3D=3D DataTypeUnicode) { + // + // unicode text + // + if (*Data =3D=3D L'L') { + Data =3D Data + 1; + } + Size =3D StrSize (Data) - sizeof (CHAR16); + if (Buffer !=3D NULL && *BufferSize >=3D Size) { + CopyMem (Buffer, Data, Size); + } else { + Status =3D EFI_BUFFER_TOO_SMALL; + } + *BufferSize =3D Size; + } else if (DataType =3D=3D DataTypeDevicePath) { + if (*Data =3D=3D L'P') { + Data =3D Data + 1; + } else if (StrnCmp (Data, L"--", 2) =3D=3D 0) { + Data =3D Data + 2; + } + DevPath =3D ConvertTextToDevicePath (Data); + if (DevPath =3D=3D NULL) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_DPFT),= gShellDebug1HiiHandle, L"setvar"); + Status =3D EFI_INVALID_PARAMETER; + } else { + Size =3D GetDevicePathSize (DevPath); + if (Buffer !=3D NULL && *BufferSize >=3D Size) { + CopyMem (Buffer, DevPath, Size); + } else { + Status =3D EFI_BUFFER_TOO_SMALL; + } + *BufferSize =3D Size; + } + SHELL_FREE_NON_NULL (DevPath); + } else { + Status =3D EFI_INVALID_PARAMETER; + } + + return Status; +} + +/** + Function to get each data from parameters. + + @param[in] Pacakge The package of checked values. + @param[out] Buffer A pointer to a buffer to hold the re= turn data. + @param[out] BufferSize Indicates the size of data in bytes = return in Buffer. + + @retval EFI_INVALID_PARAMETER Buffer or BufferSize is NULL. + @retval EFI_OUT_OF_RESOURCES A memory allcation failed. + @retval EFI_SUCCESS Get each parameter data was successf= ul. +**/ +EFI_STATUS +GetVariableDataFromParameter ( + IN CONST LIST_ENTRY *Package, + OUT UINT8 **Buffer, + OUT UINTN *BufferSize + ) +{ + CONST CHAR16 *TempData; + UINTN Index; + UINTN TotalSize; + UINTN Size; + UINT8 *BufferWalker; + EFI_STATUS Status; + + TotalSize =3D 0; + Size =3D 0; + Status =3D EFI_SUCCESS; + + if (BufferSize =3D=3D NULL || Buffer =3D=3D NULL || ShellCommandLineGetC= ount (Package) < 3) { + return EFI_INVALID_PARAMETER; + } + + for (Index =3D 2; Index < ShellCommandLineGetCount (Package); Index++) { + TempData =3D ShellCommandLineGetRawValue (Package, Index); + + if (TempData[0] !=3D L'=3D') { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gSh= ellDebug1HiiHandle, L"setvar", TempData); + return EFI_INVALID_PARAMETER; + } + + TempData =3D TempData + 1; + Size =3D 0; + Status =3D ParseParameterData (TempData, NULL, &Size); + if (EFI_ERROR (Status)) { + if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { + // + // We expect return EFI_BUFFER_TOO_SMALL when pass 'NULL' as secon= d parameter to the function ParseParameterData. + // + TotalSize +=3D Size; + } else { + if (Status =3D=3D EFI_INVALID_PARAMETER) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),= gShellDebug1HiiHandle, L"setvar", TempData); + } else if (Status =3D=3D EFI_NOT_FOUND) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_DP= FT), gShellDebug1HiiHandle, L"setvar"); + } + return Status; + } + } + } + + *BufferSize =3D TotalSize; + *Buffer =3D AllocateZeroPool (TotalSize); + + if (*Buffer =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + } else { + BufferWalker =3D *Buffer; + for (Index =3D 2; Index < ShellCommandLineGetCount (Package); Index++)= { + TempData =3D ShellCommandLineGetRawValue (Package, Index); + TempData =3D TempData + 1; + + Size =3D TotalSize; + Status =3D ParseParameterData (TempData, (VOID *)BufferWalker, &Size= ); + if (!EFI_ERROR (Status)) { + BufferWalker =3D BufferWalker + Size; + TotalSize =3D TotalSize - Size; + } else { + return Status; + } + } + } + + return EFI_SUCCESS; +} =20 /** Function for 'setvar' command. @@ -70,21 +349,18 @@ ShellCommandRunSetVar ( CHAR16 *ProblemParam; SHELL_STATUS ShellStatus; CONST CHAR16 *VariableName; - CONST CHAR16 *Data; EFI_GUID Guid; CONST CHAR16 *StringGuid; UINT32 Attributes; VOID *Buffer; UINTN Size; UINTN LoopVar; - EFI_DEVICE_PATH_PROTOCOL *DevPath; =20 ShellStatus =3D SHELL_SUCCESS; Status =3D EFI_SUCCESS; Buffer =3D NULL; Size =3D 0; Attributes =3D 0; - DevPath =3D NULL; =20 // // initialize the shell lib (we must be in non-auto-init...) @@ -111,12 +387,8 @@ ShellCommandRunSetVar ( if (ShellCommandLineGetCount(Package) < 2) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShell= Debug1HiiHandle, L"setvar"); =20 ShellStatus =3D SHELL_INVALID_PARAMETER; - } else if (ShellCommandLineGetCount(Package) > 3) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShel= lDebug1HiiHandle, L"setvar"); =20 - ShellStatus =3D SHELL_INVALID_PARAMETER; } else { VariableName =3D ShellCommandLineGetRawValue(Package, 1); - Data =3D ShellCommandLineGetRawValue(Package, 2); if (!ShellCommandLineGetFlag(Package, L"-guid")){ CopyGuid(&Guid, &gEfiGlobalVariableGuid); } else { @@ -127,54 +399,35 @@ ShellCommandRunSetVar ( ShellStatus =3D SHELL_INVALID_PARAMETER; } } - if (Data =3D=3D NULL || Data[0] !=3D L'=3D') { + + if (ShellCommandLineGetCount(Package) =3D=3D 2) { // - // Display what's there + // Display // Status =3D gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attribu= tes, &Size, Buffer); if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { Buffer =3D AllocateZeroPool(Size); Status =3D gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attri= butes, &Size, Buffer); } - if (!EFI_ERROR(Status)&& Buffer !=3D NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_PRINT), g= ShellDebug1HiiHandle, &Guid, VariableName, Size); - for (LoopVar =3D 0 ; LoopVar < Size ; LoopVar++) { + if (!EFI_ERROR(Status) && Buffer !=3D NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_SETVAR_PRINT), gS= hellDebug1HiiHandle, &Guid, VariableName, Size); + for (LoopVar =3D 0; LoopVar < Size; LoopVar++) { ShellPrintEx(-1, -1, L"%02x ", ((UINT8*)Buffer)[LoopVar]); } ShellPrintEx(-1, -1, L"\r\n"); } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_GET= ), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName); =20 - ShellStatus =3D SHELL_ACCESS_DENIED; - } - } else if (StrCmp(Data, L"=3D") =3D=3D 0) { - // - // Delete what's there! - // - Status =3D gRT->SetVariable((CHAR16*)VariableName, &Guid, Attribut= es, 0, NULL); - if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET= ), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName); =20 + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_GET= ), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName); ShellStatus =3D SHELL_ACCESS_DENIED; - } else { - ASSERT(ShellStatus =3D=3D SHELL_SUCCESS); } } else { // - // Change what's there or create a new one. - // - - ASSERT(Data[0] =3D=3D L'=3D'); - Data++; - ASSERT(Data[0] !=3D L'\0'); - - // - // Determine if the variable exists and get the attributes + // Create, Delete or Modify. // Status =3D gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attribu= tes, &Size, Buffer); if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { Buffer =3D AllocateZeroPool(Size); Status =3D gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attri= butes, &Size, Buffer); } - if (EFI_ERROR(Status) || Buffer =3D=3D NULL) { // // Creating a new variable. determine attributes from command l= ine. @@ -193,94 +446,16 @@ ShellCommandRunSetVar ( } SHELL_FREE_NON_NULL(Buffer); =20 - // - // What type is the new data. - // - if (IsStringOfHexNibbles(Data)) { - if (StrLen(Data) % 2 !=3D 0) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV)= , gShellDebug1HiiHandle, L"setvar", Data); =20 - ShellStatus =3D SHELL_INVALID_PARAMETER; - } else { - // - // arbitrary buffer - // - Buffer =3D AllocateZeroPool((StrLen(Data) / 2)); - if (Buffer =3D=3D NULL) { - Status =3D EFI_OUT_OF_RESOURCES; - } else { - StrHexToBytes (Data, StrLen (Data), Buffer, StrLen (Data) / = 2); - Status =3D gRT->SetVariable((CHAR16*)VariableName, &Guid, At= tributes, StrLen(Data) / 2, Buffer); - } - if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR= _SET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName); =20 - ShellStatus =3D SHELL_ACCESS_DENIED; - } else { - ASSERT(ShellStatus =3D=3D SHELL_SUCCESS); - } - } - } else if (StrnCmp(Data, L"\"", 1) =3D=3D 0) { - // - // ascii text - // - Data++; - Buffer =3D AllocateZeroPool(StrSize(Data) / 2); - if (Buffer =3D=3D NULL) { - Status =3D EFI_OUT_OF_RESOURCES; - } else { - AsciiSPrint(Buffer, StrSize(Data) / 2, "%s", Data); - ((CHAR8*)Buffer)[AsciiStrLen(Buffer)-1] =3D CHAR_NULL; - Status =3D gRT->SetVariable((CHAR16*)VariableName, &Guid, Attr= ibutes, AsciiStrSize(Buffer)-sizeof(CHAR8), Buffer); - } - if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_S= ET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName); =20 - ShellStatus =3D SHELL_ACCESS_DENIED; - } else { - ASSERT(ShellStatus =3D=3D SHELL_SUCCESS); - } - } else if (StrnCmp(Data, L"L\"", 2) =3D=3D 0) { - // - // ucs2 text - // - Data++; - Data++; - Buffer =3D AllocateZeroPool(StrSize(Data)); - if (Buffer =3D=3D NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), = gShellDebug1HiiHandle, L"setvar"); =20 - ShellStatus =3D SHELL_OUT_OF_RESOURCES; - } else { - UnicodeSPrint(Buffer, StrSize(Data), L"%s", Data); - ((CHAR16*)Buffer)[StrLen(Buffer)-1] =3D CHAR_NULL; - - Status =3D gRT->SetVariable((CHAR16*)VariableName, &Guid, Attr= ibutes, StrSize(Buffer)-sizeof(CHAR16), Buffer); - if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR= _SET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName); =20 - ShellStatus =3D SHELL_ACCESS_DENIED; - } else { - ASSERT(ShellStatus =3D=3D SHELL_SUCCESS); - } - } - } else if (StrnCmp(Data, L"--", 2) =3D=3D 0) { - // - // device path in text format - // - Data++; - Data++; - DevPath =3D ConvertTextToDevicePath(Data); - if (DevPath =3D=3D NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_D= PFT), gShellDebug1HiiHandle, L"setvar"); =20 - ShellStatus =3D SHELL_INVALID_PARAMETER; - } else { - Status =3D gRT->SetVariable((CHAR16*)VariableName, &Guid, Attr= ibutes, GetDevicePathSize(DevPath), DevPath); - if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR= _SET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName); =20 - ShellStatus =3D SHELL_ACCESS_DENIED; - } else { - ASSERT(ShellStatus =3D=3D SHELL_SUCCESS); - } - } + Size =3D 0; + Status =3D GetVariableDataFromParameter(Package, (UINT8 **)&Buffer= , &Size); + if (!EFI_ERROR(Status)) { + Status =3D gRT->SetVariable((CHAR16*)VariableName, &Guid, Attrib= utes, Size, Buffer); + } + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_SETVAR_ERROR_SET)= , gShellDebug1HiiHandle, L"setvar", &Guid, VariableName); + ShellStatus =3D SHELL_ACCESS_DENIED; } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), = gShellDebug1HiiHandle, L"setvar", Data); =20 - ShellStatus =3D SHELL_INVALID_PARAMETER; + ASSERT(ShellStatus =3D=3D SHELL_SUCCESS); } } } @@ -291,9 +466,5 @@ ShellCommandRunSetVar ( FreePool(Buffer); } =20 - if (DevPath !=3D NULL) { - FreePool(DevPath); - } - return (ShellStatus); } --=20 2.9.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel