Fix serious bugs related with El-Torito.

This commit is contained in:
Vreixo Formoso 2008-02-09 19:05:24 +01:00
parent 02814b0ff7
commit 9a70496d3c
3 changed files with 13 additions and 5 deletions

View File

@ -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) {

View File

@ -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++;

View File

@ -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;
}