Browse Source

Silicon/SynQuacer/OpteeRngDxe: Fix invalid parameter check

Fix invalid parameter case according to the UEFI spec 2.9,
section 37.5 EFI_RNG_PROTOCOL.GetRNG. The spec said,
"RNGValue is null or RNGValueLength is zero." instead of
"RNGValue is NULL and RNGValueLength is non-zero."

This fixes the mOpteeRng::GetRNG() to check the invalid
parameter case correctly.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
Reported-by: Kazuhiko Sakamoto <sakamoto.kazuhiko@socionext.com>
Masami Hiramatsu 2 years ago
parent
commit
3cfcf75ed4
1 changed files with 2 additions and 3 deletions
  1. 2 3
      Silicon/Socionext/SynQuacer/Drivers/OpteeRngDxe/OpteeRng.c

+ 2 - 3
Silicon/Socionext/SynQuacer/Drivers/OpteeRngDxe/OpteeRng.c

@@ -98,8 +98,7 @@ GetInfo (
   @retval EFI_NOT_READY           There is not enough random data available to
                                   satisfy the length requested by
                                   RNGValueLength.
-  @retval EFI_INVALID_PARAMETER   RNGValue is NULL and RNGValueLength is
-                                  non-zero.
+  @retval EFI_INVALID_PARAMETER   RNGValue is NULL or RNGValueLength is zero.
 
 **/
 STATIC
@@ -119,7 +118,7 @@ GetRNG (
   UINTN                      OutSize;
   UINTN                      WaitMiliSeconds;
 
-  if ((Value == NULL) && (ValueLength != 0)) {
+  if ((Value == NULL) || (ValueLength == 0)) {
     return EFI_INVALID_PARAMETER;
   }