]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_loader: avoid buffer overrun in efi_var_mem_compare
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Mon, 13 Feb 2023 18:22:33 +0000 (19:22 +0100)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sun, 19 Feb 2023 20:15:15 +0000 (21:15 +0100)
We should not scan beyond the end of string name.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
lib/efi_loader/efi_var_mem.c

index e1058e3c6aafd14e6e7a7daddcaff67aed02701c..d6b65aed12ea1001a1fe0840fa75978a0acac859 100644 (file)
@@ -41,11 +41,13 @@ efi_var_mem_compare(struct efi_var_entry *var, const efi_guid_t *guid,
             i < sizeof(efi_guid_t) && match; ++i)
                match = (guid1[i] == guid2[i]);
 
-       for (data = var->name, var_name = name;; ++data, ++var_name) {
+       for (data = var->name, var_name = name;; ++data) {
                if (match)
                        match = (*data == *var_name);
                if (!*data)
                        break;
+               if (*var_name)
+                       ++var_name;
        }
 
        ++data;