| From dc3f134436ad6852f1bad9542232e84166843a7e Mon Sep 17 00:00:00 2001 |
| From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com> |
| Date: Mon, 20 Dec 2021 20:01:10 +0000 |
| Subject: [PATCH] Add invalid parameter check in getNextVariableName() |
| |
| This patch resolves the failing tests in SCT related to |
| getNextVariableName() function. The existing implementation is |
| missing few cases where error codes are returned when called |
| with certain paramters. These conditions are implemented in |
| this patch based on the explanation provided in uefi spec. |
| |
| Upstream-Status: Pending [Not submitted to upstream yet] |
| Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com> |
| |
| |
| --- |
| .../smm_variable/backend/uefi_variable_store.c | 18 +++++++++++++++++- |
| 1 file changed, 17 insertions(+), 1 deletion(-) |
| |
| diff --git a/components/service/smm_variable/backend/uefi_variable_store.c b/components/service/smm_variable/backend/uefi_variable_store.c |
| index a1671074..a57b3346 100644 |
| --- a/components/service/smm_variable/backend/uefi_variable_store.c |
| +++ b/components/service/smm_variable/backend/uefi_variable_store.c |
| @@ -161,7 +161,7 @@ efi_status_t uefi_variable_store_set_variable( |
| bool should_sync_index = false; |
| |
| if (status != EFI_SUCCESS) return status; |
| - |
| + |
| /* |
| * Runtime access to a data variable implies boot service access. Attributes that have |
| * EFI_VARIABLE_RUNTIME_ACCESS set must also have EFI_VARIABLE_BOOTSERVICE_ACCESS set. |
| @@ -310,6 +310,22 @@ efi_status_t uefi_variable_store_get_next_variable_name( |
| status = EFI_NOT_FOUND; |
| *total_length = 0; |
| |
| + /* |
| + * If input values of VariableName and VendorGuid are not a name and GUID of an |
| + * existing variable, EFI_INVALID_PARAMETER is returned. |
| + */ |
| + if (cur->NameSize >= sizeof(int16_t)) { |
| + /* |
| + * Name must be at least one character long to accommodate |
| + * the mandatory null terminator. |
| + */ |
| + if (cur->Name[0] != 0) { |
| + const struct variable_info *var_info = variable_index_find(&context->variable_index,&cur->Guid,cur->NameSize,cur->Name); |
| + if(var_info == NULL) |
| + return EFI_INVALID_PARAMETER; |
| + } |
| + } |
| + |
| const struct variable_info *info = variable_index_find_next( |
| &context->variable_index, |
| &cur->Guid, |