Imported Debian patch 0.5.1-1
[debian/efibootmgr] / src / lib / efi.c
index 26c144a347bd6fcab745051466d5d543b8502021..ac782c9b0edc4c3d5c7afc70f32579bfa04aea25 100644 (file)
@@ -20,8 +20,9 @@
 
 #define _FILE_OFFSET_BITS 64
 
-typedef unsigned long long u64;        /* hack to allow include of ethtool.h */
+typedef unsigned long long u64;       /* hack to allow include of ethtool.h */
 
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -173,9 +174,12 @@ create_or_edit_variable(efi_variable_t *var)
 static int
 select_boot_var_names(const struct dirent *d)
 {
-       int num, rc;
-       rc = sscanf(d->d_name, "Boot0%03x-%*s", &num);
-       return rc;
+       if (!strncmp(d->d_name, "Boot", 4) &&
+           isxdigit(d->d_name[4]) && isxdigit(d->d_name[5]) &&
+           isxdigit(d->d_name[6]) && isxdigit(d->d_name[7]) &&
+           d->d_name[8] == '-')
+               return 1;
+       return 0;
 }
 
 int
@@ -718,7 +722,7 @@ make_linux_efi_variable(efi_variable_t *var,
        memset(buffer,    0, sizeof(buffer));
 
        /* VariableName needs to be BootXXXX */
-       sprintf(buffer, "Boot%04x", free_number);
+       sprintf(buffer, "Boot%04X", free_number);
 
        efichar_from_char(var->VariableName, buffer, 1024);