summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2021-09-20 17:06:01 -0400
committerPeter Jones <pjones@redhat.com>2025-01-17 17:17:20 -0500
commit9229e7caea9133484aa18178cb713f2a2f1e93d0 (patch)
tree19672ae201f01aaa04c90291d1ed01bc9512c8a5
parentb560c523623bf8b32142220401de86ed44338c3d (diff)
downloadefi-boot-shim-9229e7caea9133484aa18178cb713f2a2f1e93d0.tar.gz
efi-boot-shim-9229e7caea9133484aa18178cb713f2a2f1e93d0.zip
Make mock_set_variable() correctly account for resource usage.
When SetVariable() is called, currently the test for being out of space is correct, but the accounting is backwards - success adds more space available. This fixes the accounting and (with SHIM_DEBUG) logs the variable size. Signed-off-by: Peter Jones <pjones@redhat.com>
-rw-r--r--mock-variables.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/mock-variables.c b/mock-variables.c
index 03044549..5dc2356d 100644
--- a/mock-variables.c
+++ b/mock-variables.c
@@ -773,9 +773,9 @@ mock_set_variable(CHAR16 *name, EFI_GUID *guid, UINT32 attrs, UINTN size,
#endif
#if (defined(SHIM_DEBUG) && SHIM_DEBUG != 0)
- printf("%s:%d:%s():Setting "GUID_FMT"-%s\n",
+ printf("%s:%d:%s():Setting "GUID_FMT"-%s size:0x%"PRIx64"\n",
__FILE__, __LINE__ - 1, __func__,
- GUID_ARGS(*guid), Str2str(name));
+ GUID_ARGS(*guid), Str2str(name), size);
#endif
switch (mock_variable_sort_policy) {
case MOCK_SORT_PREPEND:
@@ -843,17 +843,17 @@ mock_set_variable(CHAR16 *name, EFI_GUID *guid, UINT32 attrs, UINTN size,
printf("%s:%d:%s():var:%p attrs:0x%lx\n",
__FILE__, __LINE__ - 1, __func__, var, attrs);
#endif
- status = mock_new_variable(name, guid, attrs, size, data, &var);
+ status = mock_sv_adjust_usage_data(attrs, size, -totalsz);
if (EFI_ERROR(status)) {
mock_sv_post_hook(name, guid, attrs, size, data,
&status, CREATE);
return status;
}
- mock_sv_adjust_usage_data(attrs, size, totalsz);
+ status = mock_new_variable(name, guid, attrs, size, data, &var);
mock_sv_post_hook(name, guid, attrs, size, data,
&status, CREATE);
if (EFI_ERROR(status)) {
- mock_sv_adjust_usage_data(attrs, 0, -totalsz);
+ mock_sv_adjust_usage_data(attrs, 0, totalsz);
return status;
}