Skip to content

Commit cb29442

Browse files
committed
menu, lib/bli: Raise menu entry path buffer limit from 256 to 1024 bytes
1 parent 47d0f20 commit cb29442

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

common/lib/bli.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <lib/bli.h>
99
#include <lib/guid.h>
1010
#include <lib/misc.h>
11+
#include <menu.h>
1112

1213
#define LIMINE_BRAND L"Limine " LIMINE_VERSION
1314

@@ -210,10 +211,10 @@ bool bli_get_oneshot_entry(char *path, size_t buf_size) {
210211
}
211212

212213
void bli_set_selected_entry(const char *path) {
213-
wchar_t wide_path[256];
214+
wchar_t wide_path[MENU_PATH_MAX];
214215
size_t len = strlen(path);
215-
if (len > 255) {
216-
len = 255;
216+
if (len > MENU_PATH_MAX - 1) {
217+
len = MENU_PATH_MAX - 1;
217218
}
218219
for (size_t pos = 0; pos < len; pos++) {
219220
wide_path[pos] = path[pos];

common/menu.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,8 +1129,8 @@ noreturn void _menu(bool first_run) {
11291129

11301130
#if defined (UEFI)
11311131
{
1132-
char path[256];
1133-
if (bli_get_oneshot_entry(path, 256)) {
1132+
char path[MENU_PATH_MAX];
1133+
if (bli_get_oneshot_entry(path, MENU_PATH_MAX)) {
11341134
// Find the entry with this path, expand directories, and get its index.
11351135
struct menu_entry *found_entry = NULL;
11361136
size_t found_index = 0;
@@ -1160,7 +1160,7 @@ noreturn void _menu(bool first_run) {
11601160
} else {
11611161
// Copy the path since find_entry_by_path calls config_get_value
11621162
// internally (via should_skip_entry), which clobbers the static buffer.
1163-
char default_entry_path[256];
1163+
char default_entry_path[MENU_PATH_MAX];
11641164
size_t len = strlen(default_entry);
11651165
if (len >= sizeof(default_entry_path)) {
11661166
len = sizeof(default_entry_path) - 1;
@@ -1181,7 +1181,7 @@ noreturn void _menu(bool first_run) {
11811181
if (!has_entry) {
11821182
char *remember_last = config_get_value(NULL, 0, "REMEMBER_LAST_ENTRY");
11831183
if (remember_last != NULL && strcasecmp(remember_last, "yes") == 0) {
1184-
char last_entry_path[256];
1184+
char last_entry_path[MENU_PATH_MAX];
11851185
UINTN getvar_size = sizeof(last_entry_path);
11861186
if (gRT->GetVariable(L"LimineLastBootedEntry",
11871187
&limine_efi_vendor_guid,
@@ -1202,8 +1202,8 @@ noreturn void _menu(bool first_run) {
12021202
}
12031203
}
12041204
if (!has_entry) {
1205-
char path[256];
1206-
if (bli_get_default_entry(path, 256)) {
1205+
char path[MENU_PATH_MAX];
1206+
if (bli_get_default_entry(path, MENU_PATH_MAX)) {
12071207
// Find the entry with this path, expand directories, and get its index.
12081208
struct menu_entry *found_entry = NULL;
12091209
size_t found_index = 0;
@@ -1497,7 +1497,7 @@ noreturn void _menu(bool first_run) {
14971497

14981498
#if defined (UEFI)
14991499
// Save the entry's path so it can persist between boots.
1500-
char entry_path[256];
1500+
char entry_path[MENU_PATH_MAX];
15011501
size_t pos = 0;
15021502
get_entry_path(selected_menu_entry, entry_path, sizeof(entry_path), &pos);
15031503
gRT->SetVariable(L"LimineLastBootedEntry",

common/menu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <stdbool.h>
55
#include <stdnoreturn.h>
66

7+
#define MENU_PATH_MAX 1024
8+
79
#if defined(UEFI)
810
bool reboot_to_fw_ui_supported(void);
911
noreturn void reboot_to_fw_ui(void);

0 commit comments

Comments
 (0)