From be09372a71ceeabf6762e84c33e9be96bafeb272 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 21 Sep 2019 06:38:11 +0200 Subject: [PATCH 1/3] efi_loader: description efi_stri_coll() Remove outdated TODO for efi_stri_coll(). efi_stri_coll() is already using the Unicode capitalization table. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_unicode_collation.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/efi_loader/efi_unicode_collation.c b/lib/efi_loader/efi_unicode_collation.c index 243c51a8dbe..c700be87560 100644 --- a/lib/efi_loader/efi_unicode_collation.c +++ b/lib/efi_loader/efi_unicode_collation.c @@ -43,11 +43,6 @@ const efi_guid_t efi_guid_unicode_collation_protocol2 = * See the Unified Extensible Firmware Interface (UEFI) specification for * details. * - * TODO: - * The implementation does not follow the Unicode collation algorithm. - * For ASCII characters it results in the same sort order as EDK2. - * We could use table UNICODE_CAPITALIZATION_TABLE for better results. - * * Return: 0: s1 == s2, > 0: s1 > s2, < 0: s1 < s2 */ static efi_intn_t EFIAPI efi_stri_coll( From edb6b6842cbddc012d64491701f1d0979ffa96b3 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 23 Sep 2019 22:18:09 +0200 Subject: [PATCH 2/3] efi_loader: SetVariable() fix illegal return We always have to return via EFI_EXIT() from EFIAPI functions. Coverity reported an unreachable line and a resource leak. Fixes: commit 6d2f27c5fd60 ("efi_loader: variable: support APPEND_WRITE") Reported-by: Coverity Scan CID 253575, CID 184095 Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_variable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 48ee255f879..22ad271bd85 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -470,7 +470,7 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, if (attributes & EFI_VARIABLE_APPEND_WRITE) { if (!prefix(old_val, "(blob)")) { - return EFI_DEVICE_ERROR; + ret = EFI_DEVICE_ERROR; goto out; } old_size = strlen(old_val); From 3545c6614342e8d91055a0f907ca7441ba00b928 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 23 Sep 2019 22:38:53 +0200 Subject: [PATCH 3/3] efi_loader: SetVariable() deleting variables APPEND_WRITE with data length zero is allowable according to the UEFI specification. The EDK2 interpretation of no access attributes is attributes = 0. As the UEFI specification is vague in this respect let's stick to EDK2 here. Fixes: commit 6d2f27c5fd60 ("efi_loader: variable: support APPEND_WRITE") Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_variable.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 22ad271bd85..4c554c546b2 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -443,8 +443,6 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, if (ret) goto out; -#define ACCESS_ATTR (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS) - old_val = env_get(native_name); if (old_val) { old_val = parse_attr(old_val, &attr); @@ -455,7 +453,9 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, goto out; } - if ((data_size == 0) || !(attributes & ACCESS_ATTR)) { + if ((data_size == 0 && + !(attributes & EFI_VARIABLE_APPEND_WRITE)) || + !attributes) { /* delete the variable: */ env_set(native_name, NULL); ret = EFI_SUCCESS; @@ -478,8 +478,9 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, old_size = 0; } } else { - if ((data_size == 0) || !(attributes & ACCESS_ATTR) || - (attributes & EFI_VARIABLE_APPEND_WRITE)) { + if ((data_size == 0 && + !(attributes & EFI_VARIABLE_APPEND_WRITE)) || + !attributes) { /* delete, but nothing to do */ ret = EFI_NOT_FOUND; goto out;