public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Dong, Eric" <eric.dong@intel.com>
To: "Bi, Dandan" <dandan.bi@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Zhang, Chao B" <chao.b.zhang@intel.com>
Subject: Re: [patch] Security/OpalHii.c: Handle NULL Request or Request with no elements
Date: Mon, 16 Oct 2017 05:04:24 +0000	[thread overview]
Message-ID: <ED077930C258884BBCB450DB737E66224AA30898@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <1508125028-85644-1-git-send-email-dandan.bi@intel.com>

Reviewed-by: Eric Dong <eric.dong@intel.com>

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Dandan Bi
> Sent: Monday, October 16, 2017 11:37 AM
> To: edk2-devel@lists.01.org
> Cc: Dong, Eric <eric.dong@intel.com>; Zhang, Chao B
> <chao.b.zhang@intel.com>
> Subject: [edk2] [patch] Security/OpalHii.c: Handle NULL Request or Request
> with no elements
> 
> According to UEFI spec, for the ExtractConfig function in
> EFI_HII_CONFIG_ACCESS_PROTOCOL,If a NULL is passed in for the Request
> field or if a ConfigHdr is passed in with no request elements, all of the
> settings being abstracted by this function will be returned in the Results field.
> 
> The implementation of ExtractConfig function in OpalHii.c misses to handle
> above cases.This patch is to do the enhancements.
> 
> Cc: Chao Zhang <chao.b.zhang@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Dandan Bi <dandan.bi@intel.com>
> ---
>  SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c | 46
> +++++++++++++++++++++++++-
>  1 file changed, 45 insertions(+), 1 deletion(-)
> 
> diff --git a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c
> b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c
> index 4881e72..e3bde42 100644
> --- a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c
> +++ b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c
> @@ -1278,10 +1278,16 @@ ExtractConfig(
>    EFI_STRING                              *Progress,
>    EFI_STRING                              *Results
>    )
>  {
>    EFI_STATUS                              Status;
> +  EFI_STRING                              ConfigRequest;
> +  EFI_STRING                              ConfigRequestHdr;
> +  UINTN                                   BufferSize;
> +  UINTN                                   Size;
> +  BOOLEAN                                 AllocatedRequest;
> +  EFI_HANDLE                              DriverHandle;
> 
>    //
>    // Check for valid parameters
>    //
>    if (Progress == NULL || Results == NULL) { @@ -1292,22 +1298,60 @@
> ExtractConfig(
>    if ((Request != NULL) &&
>      !HiiIsConfigHdrMatch (Request, &gHiiSetupVariableGuid,
> OpalPasswordStorageName)) {
>      return EFI_NOT_FOUND;
>    }
> 
> +  AllocatedRequest = FALSE;
> +  BufferSize = sizeof (OPAL_HII_CONFIGURATION);  ConfigRequest =
> + Request;  if ((Request == NULL) || (StrStr (Request, L"OFFSET") ==
> + NULL)) {
> +    //
> +    // Request has no request element, construct full request string.
> +    // Allocate and fill a buffer large enough to hold the <ConfigHdr>
> template
> +    // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW"
> followed by a Null-terminator
> +    //
> +    DriverHandle = HiiGetDriverImageHandleCB();
> +    ConfigRequestHdr = HiiConstructConfigHdr (&gHiiSetupVariableGuid,
> OpalPasswordStorageName, DriverHandle);
> +    Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
> +    ConfigRequest = AllocateZeroPool (Size);
> +    if (ConfigRequest == NULL) {
> +      return EFI_OUT_OF_RESOURCES;
> +    }
> +    AllocatedRequest = TRUE;
> +    UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX",
> ConfigRequestHdr, (UINT64)BufferSize);
> +    FreePool (ConfigRequestHdr);
> +  }
> +
>    //
>    // Convert Buffer Data to <ConfigResp> by helper function BlockToConfig( )
>    //
>    Status = gHiiConfigRouting->BlockToConfig(
>                 gHiiConfigRouting,
> -               Request,
> +               ConfigRequest,
>                 (UINT8*)&gHiiConfiguration,
>                 sizeof(OPAL_HII_CONFIGURATION),
>                 Results,
>                 Progress
>             );
> 
> +  //
> +  // Free the allocated config request string.
> +  //
> +  if (AllocatedRequest) {
> +    FreePool (ConfigRequest);
> +    ConfigRequest = NULL;
> +  }
> +
> +  //
> +  // Set Progress string to the original request string.
> +  //
> +  if (Request == NULL) {
> +    *Progress = NULL;
> +  } else if (StrStr (Request, L"OFFSET") == NULL) {
> +    *Progress = Request + StrLen (Request);  }
> +
>    return (Status);
>  }
> 
> 
>  /**
> --
> 1.9.5.msysgit.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


      reply	other threads:[~2017-10-16  5:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-16  3:37 [patch] Security/OpalHii.c: Handle NULL Request or Request with no elements Dandan Bi
2017-10-16  5:04 ` Dong, Eric [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ED077930C258884BBCB450DB737E66224AA30898@shsmsx102.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox