:: commit cb29442a85e506409dc09c0a6ce5998d49a69be8

Mintsuki <mintsuki@protonmail.com> — 2026-04-18 00:01

parents: 47d0f207fb

menu, lib/bli: Raise menu entry path buffer limit from 256 to 1024 bytes

diff --git a/common/lib/bli.c b/common/lib/bli.c
index 3ceb646b..644fb98d 100644
--- a/common/lib/bli.c
+++ b/common/lib/bli.c
@@ -8,6 +8,7 @@
 #include <lib/bli.h>
 #include <lib/guid.h>
 #include <lib/misc.h>
+#include <menu.h>
 
 #define LIMINE_BRAND L"Limine " LIMINE_VERSION
 
@@ -210,10 +211,10 @@ bool bli_get_oneshot_entry(char *path, size_t buf_size) {
 }
 
 void bli_set_selected_entry(const char *path) {
-    wchar_t wide_path[256];
+    wchar_t wide_path[MENU_PATH_MAX];
     size_t len = strlen(path);
-    if (len > 255) {
-        len = 255;
+    if (len > MENU_PATH_MAX - 1) {
+        len = MENU_PATH_MAX - 1;
     }
     for (size_t pos = 0; pos < len; pos++) {
         wide_path[pos] = path[pos];
diff --git a/common/menu.c b/common/menu.c
index c5742ca0..f69eb616 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -1129,8 +1129,8 @@ noreturn void _menu(bool first_run) {
 
 #if defined (UEFI)
     {
-        char path[256];
-        if (bli_get_oneshot_entry(path, 256)) {
+        char path[MENU_PATH_MAX];
+        if (bli_get_oneshot_entry(path, MENU_PATH_MAX)) {
             // Find the entry with this path, expand directories, and get its index.
             struct menu_entry *found_entry = NULL;
             size_t found_index = 0;
@@ -1160,7 +1160,7 @@ noreturn void _menu(bool first_run) {
             } else {
                 // Copy the path since find_entry_by_path calls config_get_value
                 // internally (via should_skip_entry), which clobbers the static buffer.
-                char default_entry_path[256];
+                char default_entry_path[MENU_PATH_MAX];
                 size_t len = strlen(default_entry);
                 if (len >= sizeof(default_entry_path)) {
                     len = sizeof(default_entry_path) - 1;
@@ -1181,7 +1181,7 @@ noreturn void _menu(bool first_run) {
     if (!has_entry) {
         char *remember_last = config_get_value(NULL, 0, "REMEMBER_LAST_ENTRY");
         if (remember_last != NULL && strcasecmp(remember_last, "yes") == 0) {
-            char last_entry_path[256];
+            char last_entry_path[MENU_PATH_MAX];
             UINTN getvar_size = sizeof(last_entry_path);
             if (gRT->GetVariable(L"LimineLastBootedEntry",
                                  &limine_efi_vendor_guid,
@@ -1202,8 +1202,8 @@ noreturn void _menu(bool first_run) {
         }
     }
     if (!has_entry) {
-        char path[256];
-        if (bli_get_default_entry(path, 256)) {
+        char path[MENU_PATH_MAX];
+        if (bli_get_default_entry(path, MENU_PATH_MAX)) {
             // Find the entry with this path, expand directories, and get its index.
             struct menu_entry *found_entry = NULL;
             size_t found_index = 0;
@@ -1497,7 +1497,7 @@ timeout_aborted:
 
 #if defined (UEFI)
                 // Save the entry's path so it can persist between boots.
-                char entry_path[256];
+                char entry_path[MENU_PATH_MAX];
                 size_t pos = 0;
                 get_entry_path(selected_menu_entry, entry_path, sizeof(entry_path), &pos);
                 gRT->SetVariable(L"LimineLastBootedEntry",
diff --git a/common/menu.h b/common/menu.h
index 38f48f6f..acaa65c5 100644
--- a/common/menu.h
+++ b/common/menu.h
@@ -4,6 +4,8 @@
 #include <stdbool.h>
 #include <stdnoreturn.h>
 
+#define MENU_PATH_MAX 1024
+
 #if defined(UEFI)
 bool reboot_to_fw_ui_supported(void);
 noreturn void reboot_to_fw_ui(void);
tab: 248 wrap: offon