From: Christian Storm <[email protected]>
Signed-off-by: Christian Storm <[email protected]>
---
env/fatvars.c | 17 ++++++++++++-----
include/utils.h | 1 -
utils.c | 8 --------
3 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/env/fatvars.c b/env/fatvars.c
index 4cf580d..7046353 100644
--- a/env/fatvars.c
+++ b/env/fatvars.c
@@ -14,6 +14,7 @@
#include <efi.h>
#include <efilib.h>
+#include <efiapi.h>
#include <bootguard.h>
#include <utils.h>
#include <syspart.h>
@@ -61,9 +62,12 @@ BG_STATUS save_current_config(void)
}
UINTN writelen = sizeof(BG_ENVDATA);
- uint32_t crc32 = calc_crc32(&env[current_partition],
- sizeof(BG_ENVDATA) -
- sizeof(env[current_partition].crc32));
+
+ uint32_t crc32;
+ (VOID) uefi_call_wrapper(
+ BS->CalculateCrc32, 3, &env[current_partition],
+ sizeof(BG_ENVDATA) - sizeof(env[current_partition].crc32), &crc32);
+
env[current_partition].crc32 = crc32;
efistatus = uefi_call_wrapper(fh->Write, 3, fh, &writelen,
(VOID *)&env[current_partition]);
@@ -142,8 +146,11 @@ BG_STATUS load_config(BG_LOADER_PARAMS *bglp)
continue;
}
- uint32_t crc32 = calc_crc32(&env[i], sizeof(BG_ENVDATA) -
- sizeof(env[i].crc32));
+ uint32_t crc32;
+ (VOID) uefi_call_wrapper(
+ BS->CalculateCrc32, 3, &env[i],
+ sizeof(BG_ENVDATA) - sizeof(env[i].crc32), &crc32);
+
if (crc32 != env[i].crc32) {
ERROR(L"CRC32 error in environment data on config
partition %d.\n",
i);
diff --git a/include/utils.h b/include/utils.h
index 825a647..f83d6b4 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -32,7 +32,6 @@ extern UINTN volume_count;
typedef enum { DOSFSLABEL, CUSTOMLABEL, NOLABEL } LABELMODE;
-uint32_t calc_crc32(void *data, int32_t size);
void __attribute__((noreturn)) error_exit(CHAR16 *message, EFI_STATUS status);
CHAR16 *get_volume_label(EFI_FILE_HANDLE fh);
EFI_STATUS get_volumes(VOLUME_DESC **volumes, UINTN *count);
diff --git a/utils.c b/utils.c
index 9f59b1e..ace4689 100644
--- a/utils.c
+++ b/utils.c
@@ -49,14 +49,6 @@ BOOLEAN IsOnBootMedium(EFI_DEVICE_PATH *dp)
return result;
}
-uint32_t calc_crc32(void *data, int32_t size)
-{
- uint32_t crc;
-
- uefi_call_wrapper(BS->CalculateCrc32, 3, data, size, &crc);
- return crc;
-}
-
void __attribute__((noreturn)) error_exit(CHAR16 *message, EFI_STATUS status)
{
ERROR(L"%s ( %r )\n", message, status);
--
2.30.0
--
You received this message because you are subscribed to the Google Groups "EFI
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/efibootguard-dev/20210127080521.5542-1-christian.storm%40siemens.com.