chainload_next: Fix some UEFI bugs
diff --git a/common/protos/chainload_next.c b/common/protos/chainload_next.c
index 791d5671..bf1559c7 100644
--- a/common/protos/chainload_next.c
+++ b/common/protos/chainload_next.c
@@ -15,12 +15,13 @@ static void try(char *config, struct volume *v) {
#if uefi == 1
static void try(char *config, struct volume *v) {
- for (int i = 0; i < v->max_partition + 1; i++) {
+ for (int i = 0; i <= v->max_partition + 1; i++) {
struct file_handle *image;
+ struct volume *p = volume_get_by_coord(v->is_optical, v->index, i);
- if ((image = fopen(v, "/EFI/BOOT/BOOTX64.EFI")) == NULL
- && (image = fopen(v, "/efi/boot/bootx64.efi")) == NULL
- && (image = fopen(v, "/EFI/BOOT/BOOTx64.efi")) == NULL) {
+ if ((image = fopen(p, "/EFI/BOOT/BOOTX64.EFI")) == NULL
+ && (image = fopen(p, "/efi/boot/bootx64.efi")) == NULL
+ && (image = fopen(p, "/EFI/BOOT/BOOTx64.EFI")) == NULL) {
continue;
}
