diff --git a/demo/iso_modify.c b/demo/iso_modify.c index ad17487..85404ce 100644 --- a/demo/iso_modify.c +++ b/demo/iso_modify.c @@ -86,6 +86,7 @@ int main(int argc, char **argv) printf("Cant create write opts, error %d\n", result); return 1; } + /* for isolinux: iso_write_opts_set_allow_full_ascii(opts, 1); */ result = iso_image_create_burn_source(image, opts, &burn_src); if (result < 0) { diff --git a/libisofs/eltorito.c b/libisofs/eltorito.c index 8b0c9dd..f8e94c9 100644 --- a/libisofs/eltorito.c +++ b/libisofs/eltorito.c @@ -502,8 +502,7 @@ write_validation_entry(uint8_t *buf) /* calculate the checksum, to ensure sum of all words is 0 */ checksum = 0; for (i = 0; i < sizeof(struct el_torito_validation_entry); i += 2) { - checksum -= buf[i]; - checksum -= (buf[i] << 8); + checksum -= (int16_t) ((buf[i+1] << 8) | buf[i]); } iso_lsb(ve->checksum, checksum, 2); } @@ -775,8 +774,6 @@ int patch_boot_image(uint8_t *buf, Ecma119Image *t, size_t imgsize) "Isolinux image too small. We won't patch it."); } - memset(&info, 0, sizeof(info)); - /* compute checksum, as the the sum of all 32 bit words in boot image * from offset 64 */ checksum = 0; @@ -794,7 +791,7 @@ int patch_boot_image(uint8_t *buf, Ecma119Image *t, size_t imgsize) /* patch boot info table */ info = (struct boot_info_table*)(buf + 8); - memset(info, 0, sizeof(struct boot_info_table)); + /*memset(info, 0, sizeof(struct boot_info_table));*/ iso_lsb(info->bi_pvd, t->ms_block + 16, 4); iso_lsb(info->bi_file, t->bootimg->block, 4); iso_lsb(info->bi_length, imgsize, 4); @@ -903,6 +900,11 @@ int eltorito_writer_create(Ecma119Image *target) return ret; } target->bootimg = src; + + /* if we have selected to patch the image, it needs to be copied always */ + if (target->catalog->image->isolinux) { + src->prev_img = 0; + } /* we need the bootable volume descriptor */ target->curblock++; diff --git a/libisofs/stream.c b/libisofs/stream.c index c264065..710ed8f 100644 --- a/libisofs/stream.c +++ b/libisofs/stream.c @@ -284,8 +284,13 @@ int mem_read(IsoStream *stream, void *buf, size_t count) return ISO_FILE_NOT_OPENNED; } + if (data->offset >= data->size) { + return 0; /* EOF */ + } + len = MIN(count, data->size - data->offset); memcpy(buf, data->buf + data->offset, len); + data->offset += len; return len; }