]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
efivars: make sure efi_loader_entry_name_valid() is always compiled in
authorLennart Poettering <lennart@poettering.net>
Mon, 11 Mar 2019 14:58:52 +0000 (15:58 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 11 Mar 2019 20:12:23 +0000 (21:12 +0100)
The string validation should always be done correctly, and not fail just
because EFI is turned off. After all an EFI loader entry name string
remains properly formatted regardless if EFI is on or off...

Fixes: #11948
src/shared/efivars.c
src/shared/efivars.h

index 885f03118a5fbd133474281e6075a968137f4e0c..04c0a697b4803fc31b6691370097c85a1d4d1172 100644 (file)
@@ -789,16 +789,6 @@ int efi_loader_get_device_part_uuid(sd_id128_t *u) {
         return 0;
 }
 
-bool efi_loader_entry_name_valid(const char *s) {
-        if (isempty(s))
-                return false;
-
-        if (strlen(s) > FILENAME_MAX) /* Make sure entry names fit in filenames */
-                return false;
-
-        return in_charset(s, ALPHANUMERICAL "-_.");
-}
-
 int efi_loader_get_entries(char ***ret) {
         _cleanup_free_ char16_t *entries = NULL;
         _cleanup_strv_free_ char **l = NULL;
@@ -903,6 +893,16 @@ int efi_loader_get_features(uint64_t *ret) {
 
 #endif
 
+bool efi_loader_entry_name_valid(const char *s) {
+        if (isempty(s))
+                return false;
+
+        if (strlen(s) > FILENAME_MAX) /* Make sure entry names fit in filenames */
+                return false;
+
+        return in_charset(s, ALPHANUMERICAL "-_.");
+}
+
 char *efi_tilt_backslashes(char *s) {
         char *p;
 
index a545cd47b4caefdbcfefd0213369b495304b227d..d8f18aae90e1d3bb893295e760c5d1fbd45d8ccb 100644 (file)
@@ -50,8 +50,6 @@ int efi_loader_get_boot_usec(usec_t *firmware, usec_t *loader);
 
 int efi_loader_get_entries(char ***ret);
 
-bool efi_loader_entry_name_valid(const char *s);
-
 int efi_loader_get_features(uint64_t *ret);
 
 #else
@@ -132,14 +130,12 @@ static inline int efi_loader_get_entries(char ***ret) {
         return -EOPNOTSUPP;
 }
 
-static inline bool efi_loader_entry_name_valid(const char *s) {
-        return false;
-}
-
 static inline int efi_loader_get_features(uint64_t *ret) {
         return -EOPNOTSUPP;
 }
 
 #endif
 
+bool efi_loader_entry_name_valid(const char *s);
+
 char *efi_tilt_backslashes(char *s);