efi_loader: variable: check a return value of uuid__str_to_bin()
authorAKASHI Takahiro <takahiro.akashi@linaro.org>
Fri, 8 May 2020 05:51:21 +0000 (14:51 +0900)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Sat, 9 May 2020 07:30:27 +0000 (09:30 +0200)
The only error case is that a given UUID is in wrong format.
So just return EFI_INVALID_PARAMETER here.

Reported-by: Coverity (CID 300333)
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
lib/efi_loader/efi_variable.c

index 60c1201757842f59b07291cf130e07ebdc048902..10892684d1b22bde8fbcfc47ecc239037064a3b0 100644 (file)
@@ -767,7 +767,10 @@ static efi_status_t parse_uboot_variable(char *variable,
        /* guid */
        c = *(name - 1);
        *(name - 1) = '\0'; /* guid need be null-terminated here */
-       uuid_str_to_bin(guid, (unsigned char *)vendor, UUID_STR_FORMAT_GUID);
+       if (uuid_str_to_bin(guid, (unsigned char *)vendor,
+                           UUID_STR_FORMAT_GUID))
+               /* The only error would be EINVAL. */
+               return EFI_INVALID_PARAMETER;
        *(name - 1) = c;
 
        /* attributes */