From 4b21386e82d4eb627bcd8d6a21dfecbe09a6d5e2 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Thu, 18 Apr 2019 10:49:40 +0200 Subject: [PATCH] Bug fix: SIGSEGV happened if options bit 14 of iso_write_opts_set_system_area() is set and no El Torito boot image is defined --- libisofs/system_area.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libisofs/system_area.c b/libisofs/system_area.c index ab1ba8a..eb26938 100644 --- a/libisofs/system_area.c +++ b/libisofs/system_area.c @@ -2145,7 +2145,7 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf) return ISO_ASSERT_FAILURE; } - /* This eventually overwrites the non-mbr_req partition table entries + /* This possibly overwrites the non-mbr_req partition table entries made so far. Overwriting those from t->mbr_req is not allowed. */ if (sa_type == 3 || !t->opts->appended_as_gpt) { @@ -2175,6 +2175,9 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf) if (sa_type == 0 && (t->system_area_options & 0x4000) && !do_isohybrid) { /* Patch MBR for GRUB2 */ + if (t->num_bootsrc <= 0) + return iso_msg_submit(t->image->id, ISO_BOOT_IMAGE_NOT_VALID, 0, + "No boot image found as jump target for GRUB2 MBR."); if (t->bootsrc[0] == NULL) return iso_msg_submit(t->image->id, ISO_BOOT_IMAGE_NOT_VALID, 0, "Cannot refer by GRUB2 MBR to data outside of ISO 9660 filesystem.");