[PATCH 1/1] cmd/efidebug: do not allow invalid boot order

Heinrich Schuchardt <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <[email protected]>
The `efidebug boot order` command should not allow to create a boot order
containing non-existent boot options.

Signed-off-by: Heinrich Schuchardt <[email protected]>
---
 cmd/efidebug.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index a6faa36b500..e2739b1df04 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -1423,12 +1423,28 @@ static int do_efi_boot_order(struct cmd_tbl *cmdtp, int flag,
 		return CMD_RET_FAILURE;
 
 	for (i = 0; i < argc; i++) {
+		u16 var_name16[9];
+		efi_uintn_t size;
+		efi_status_t ret;
+
 		id = (int)hextoul(argv[i], &endp);
 		if (*endp != '\0' || id > 0xffff) {
 			printf("invalid value: %s\n", argv[i]);
 			r = CMD_RET_FAILURE;
 			goto out;
 		}
+		efi_create_indexed_name(var_name16, sizeof(var_name16),
+					"Boot", id);
+
+		size = 0;
+		ret = efi_get_variable_int(var_name16,
+					   &efi_global_variable_guid, NULL,
+					   &size, NULL, NULL);
+		if (ret != EFI_BUFFER_TOO_SMALL) {
+			printf("%ls not defined\n", var_name16);
+			r = CMD_RET_FAILURE;
+			goto out;
+		}
 
 		bootorder[i] = (u16)id;
 	}
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.