diff --git a/libisofs/eltorito.c b/libisofs/eltorito.c index 41a543a..0fe20ca 100644 --- a/libisofs/eltorito.c +++ b/libisofs/eltorito.c @@ -1178,10 +1178,10 @@ int iso_patch_eltoritos(Ecma119Image *t) continue; original = t->bootsrc[idx]->stream; size = (size_t) iso_stream_get_size(original); - - /* >>> BOOT ts B00428 : - check whether size is not too large for buffering */; - + if (size > Libisofs_elto_max_patchablE) + return ISO_PATCH_OVERSIZED_BOOT; + if (iso_stream_get_input_stream(original, 0) != NULL) + return ISO_PATCH_FILTERED_BOOT; buf = calloc(1, size); if (buf == NULL) { return ISO_OUT_OF_MEM; diff --git a/libisofs/eltorito.h b/libisofs/eltorito.h index 64ce050..7eb1bbb 100644 --- a/libisofs/eltorito.h +++ b/libisofs/eltorito.h @@ -168,4 +168,11 @@ int iso_patch_eltoritos(Ecma119Image *t); #define Libisofs_grub2_elto_patch_offsT 5 +/* Maximum size of a boot image which is marked by + el_torito_set_isolinux_options() for patching (boot info table, + GRUB2 boot info, maybe others). +*/ +#define Libisofs_elto_max_patchablE (32 * 1024 * 1024) + + #endif /* LIBISO_ELTORITO_H */ diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 60d8985..3220ba9 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -8312,6 +8312,14 @@ int iso_conv_name_chars(IsoWriteOpts *opts, char *name, size_t name_len, (NOTE, HIGH, -409) */ #define ISO_NOT_REPRODUCIBLE 0xB030FE67 +/** May not write boot info into filtered stream of boot image + (FAILURE, HIGH, -410) */ +#define ISO_PATCH_FILTERED_BOOT 0xE830FE66 + +/** Boot image to large to buffer for writing boot info + (FAILURE, HIGH, -411) */ +#define ISO_PATCH_OVERSIZED_BOOT 0xE830FE65 + /* Internal developer note: Place new error codes directly above this comment. diff --git a/libisofs/messages.c b/libisofs/messages.c index 78921b1..18d0d40 100644 --- a/libisofs/messages.c +++ b/libisofs/messages.c @@ -531,6 +531,10 @@ const char *iso_error_to_msg(int errcode) return "Unreadable file, premature EOF, or failure to seek for interval reader"; case ISO_NOT_REPRODUCIBLE: return "Cannot arrange content of data files in surely reproducible way"; + case ISO_PATCH_FILTERED_BOOT: + return "May not write boot info into filtered stream of boot image"; + case ISO_PATCH_OVERSIZED_BOOT: + return "Boot image to large to buffer for writing boot info"; default: return "Unknown error"; }