Why remove this from the expression?  Is it redundant?
-  } else if (NextCommandLine[0] != CHAR_NULL &&

Reviewed-by: Jaben Carsey <jaben.car...@intel.com>

> -----Original Message-----
> From: Qiu, Shumin
> Sent: Thursday, September 10, 2015 8:16 PM
> To: edk2-devel@lists.01.org
> Cc: Qiu, Shumin <shumin....@intel.com>; Carsey, Jaben
> <jaben.car...@intel.com>
> Subject: [PATCH] ShellPkg: Fix Shell does not support ASCII pipe(|a).
> Importance: High
> 
> Cc: Jaben Carsey <jaben.car...@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Qiu Shumin <shumin....@intel.com>
> ---
>  ShellPkg/Application/Shell/Shell.c | 36 +++++++++++++++++++++++++------
> -----
>  1 file changed, 25 insertions(+), 11 deletions(-)
> 
> diff --git a/ShellPkg/Application/Shell/Shell.c
> b/ShellPkg/Application/Shell/Shell.c
> index 78a64de..03f5e4f 100644
> --- a/ShellPkg/Application/Shell/Shell.c
> +++ b/ShellPkg/Application/Shell/Shell.c
> @@ -1578,11 +1578,18 @@ RunSplitCommand(
>      SHELL_FREE_NON_NULL(OurCommandLine);
>      SHELL_FREE_NON_NULL(NextCommandLine);
>      return (EFI_INVALID_PARAMETER);
> -  } else if (NextCommandLine[0] != CHAR_NULL &&
> -      NextCommandLine[0] == L'a' &&
> -      NextCommandLine[1] == L' '
> -     ){
> +  } else if (NextCommandLine[0] == L'a' &&
> +             (NextCommandLine[1] == L' ' || NextCommandLine[1] ==
> CHAR_NULL)
> +            ){
>      CopyMem(NextCommandLine, NextCommandLine+1,
> StrSize(NextCommandLine) - sizeof(NextCommandLine[0]));
> +    while (NextCommandLine[0] == L' ') {
> +      CopyMem(NextCommandLine, NextCommandLine+1,
> StrSize(NextCommandLine) - sizeof(NextCommandLine[0]));
> +    }
> +    if (NextCommandLine[0] == CHAR_NULL) {
> +      SHELL_FREE_NON_NULL(OurCommandLine);
> +      SHELL_FREE_NON_NULL(NextCommandLine);
> +      return (EFI_INVALID_PARAMETER);
> +    }
>      Unicode = FALSE;
>    } else {
>      Unicode = TRUE;
> @@ -1884,24 +1891,31 @@ VerifySplit(
>    EFI_STATUS    Status;
> 
>    //
> -  // Verify up to the pipe or end character
> +  // If this was the only item, then get out
>    //
> -  Status = IsValidSplit(CmdLine);
> -  if (EFI_ERROR(Status)) {
> -    return (Status);
> +  if (!ContainsSplit(CmdLine)) {
> +    return (EFI_SUCCESS);
>    }
> 
>    //
> -  // If this was the only item, then get out
> +  // Verify up to the pipe or end character
>    //
> -  if (!ContainsSplit(CmdLine)) {
> -    return (EFI_SUCCESS);
> +  Status = IsValidSplit(CmdLine);
> +  if (EFI_ERROR(Status)) {
> +    return (Status);
>    }
> 
>    //
>    // recurse to verify the next item
>    //
>    TempSpot = FindFirstCharacter(CmdLine, L"|", L'^') + 1;
> +  if (*TempSpot == L'a' &&
> +      (*(TempSpot + 1) == L' ' || *(TempSpot + 1) == CHAR_NULL)
> +     ) {
> +    // If it's an ASCII pipe '|a'
> +    TempSpot += 1;
> +  }
> +
>    return (VerifySplit(TempSpot));
>  }
> 
> --
> 1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to