diff options
| author | Steve McIntyre <steve@einval.com> | 2024-02-17 17:35:37 +0000 |
|---|---|---|
| committer | Steve McIntyre <steve@einval.com> | 2024-05-03 14:36:51 +0100 |
| commit | f898e219b4b06cf2bb7af18b5cc7a00754d3d274 (patch) | |
| tree | c535b3ff1b13388dbaa7072c7f5ec78f5d73ee53 /mok.c | |
| parent | 3cf4042d82ef314f19e9f7bd4f86c4b59efd8233 (diff) | |
| download | efi-boot-shim-f898e219b4b06cf2bb7af18b5cc7a00754d3d274.tar.gz efi-boot-shim-f898e219b4b06cf2bb7af18b5cc7a00754d3d274.zip | |
New upstream version 15.8
Diffstat (limited to 'mok.c')
| -rw-r--r-- | mok.c | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -291,7 +291,7 @@ mirror_one_esl(CHAR16 *name, EFI_GUID *guid, UINT32 attrs, &var, &varsz); if (EFI_ERROR(efi_status) || !var || !varsz) { LogError(L"Couldn't allocate %lu bytes for mok variable \"%s\": %r\n", - varsz, var, efi_status); + varsz, name, efi_status); return efi_status; } @@ -302,7 +302,7 @@ mirror_one_esl(CHAR16 *name, EFI_GUID *guid, UINT32 attrs, FreePool(var); if (EFI_ERROR(efi_status)) { LogError(L"Couldn't create mok variable \"%s\": %r\n", - varsz, var, efi_status); + name, efi_status); return efi_status; } @@ -423,12 +423,20 @@ mirror_mok_db(CHAR16 *name, CHAR8 *name8, EFI_GUID *guid, UINT32 attrs, } /* The name counts towards the size of the variable */ - max_var_sz -= (StrLen(namen) + 1) * 2; + SIZE_T namen_sz = (StrLen(namen) + 1) * 2; + if (max_var_sz > namen_sz) + max_var_sz -= namen_sz; + else + max_var_sz = 0; dprint(L"max_var_sz - name: %lx\n", max_var_sz); SIZE_T howmany; - howmany = MIN((max_var_sz - sizeof(*esl)) / esl->SignatureSize, - (esl_end_pos - pos) / esl->SignatureSize); + if (max_var_sz > sizeof(*esl)) + howmany = MIN((max_var_sz - sizeof(*esl)) / esl->SignatureSize, + (esl_end_pos - pos) / esl->SignatureSize); + else + howmany = 0; + if (howmany == 0) { /* No signatures from this ESL can be mirrored in to a * single variable, so skip it. |
