]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_loader: parameter checks CalculateCrc32()
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Thu, 16 May 2019 21:31:29 +0000 (23:31 +0200)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Sun, 19 May 2019 06:10:10 +0000 (08:10 +0200)
Not checking the parameters may lead reading or writing from NULL.
Implement the parameter checks prescribed in the UEFI spec.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
lib/efi_loader/efi_boottime.c

index d3f21f15b703b51d10b0bcaf1dc803c9609ba4f1..ce6ca06f75b4842d2b3a548601d112bf9e52321b 100644 (file)
@@ -2465,9 +2465,16 @@ static efi_status_t EFIAPI efi_calculate_crc32(const void *data,
                                               efi_uintn_t data_size,
                                               u32 *crc32_p)
 {
+       efi_status_t ret = EFI_SUCCESS;
+
        EFI_ENTRY("%p, %zu", data, data_size);
+       if (!data || !data_size || !crc32_p) {
+               ret = EFI_INVALID_PARAMETER;
+               goto out;
+       }
        *crc32_p = crc32(0, data, data_size);
-       return EFI_EXIT(EFI_SUCCESS);
+out:
+       return EFI_EXIT(ret);
 }
 
 /**