Bug fix: Random checksum index could sneak in via boot catalog node

and cause a SIGSEGV if checksumming is enabled.
This and other occurences of malloc() were changed to calloc().
This commit is contained in:
Thomas Schmitt 2010-02-08 13:46:45 +01:00
parent 3951df25be
commit afebbe187d
2 changed files with 8 additions and 7 deletions

View File

@ -408,7 +408,7 @@ int iso_image_set_boot_image(IsoImage *image, const char *image_path,
}
/* creates the catalog with the given image */
catalog = malloc(sizeof(struct el_torito_boot_catalog));
catalog = calloc(1, sizeof(struct el_torito_boot_catalog));
if (catalog == NULL) {
ret = ISO_OUT_OF_MEM;
goto boot_image_cleanup;
@ -703,11 +703,11 @@ int catalog_stream_new(Ecma119Image *target, IsoStream **stream)
return ISO_NULL_POINTER;
}
str = malloc(sizeof(IsoStream));
str = calloc(1, sizeof(IsoStream));
if (str == NULL) {
return ISO_OUT_OF_MEM;
}
data = malloc(sizeof(struct catalog_stream));
data = calloc(1, sizeof(struct catalog_stream));
if (str == NULL) {
free(str);
return ISO_OUT_OF_MEM;
@ -741,7 +741,7 @@ int el_torito_catalog_file_src_create(Ecma119Image *target, IsoFileSrc **src)
return ISO_SUCCESS;
}
file = malloc(sizeof(IsoFileSrc));
file = calloc(1, sizeof(IsoFileSrc));
if (file == NULL) {
return ISO_OUT_OF_MEM;
}
@ -754,6 +754,7 @@ int el_torito_catalog_file_src_create(Ecma119Image *target, IsoFileSrc **src)
/* fill fields */
file->prev_img = 0; /* TODO allow copy of old img catalog???? */
file->checksum_index = 0;
file->nsections = 1;
file->sections = calloc(1, sizeof(struct iso_file_section));
file->sort_weight = 1000; /* slightly high */
@ -840,7 +841,7 @@ int eltorito_writer_compute_data_blocks(IsoImageWriter *writer)
IsoStream *new = NULL;
IsoStream *original = t->bootimg->stream;
size = (size_t) iso_stream_get_size(original);
buf = malloc(size);
buf = calloc(1, size);
if (buf == NULL) {
return ISO_OUT_OF_MEM;
}
@ -922,7 +923,7 @@ int eltorito_writer_create(Ecma119Image *target)
IsoFile *bootimg;
IsoFileSrc *src;
writer = malloc(sizeof(IsoImageWriter));
writer = calloc(1, sizeof(IsoImageWriter));
if (writer == NULL) {
return ISO_OUT_OF_MEM;
}

View File

@ -556,7 +556,7 @@ int iso_file_src_writer_create(Ecma119Image *target)
{
IsoImageWriter *writer;
writer = malloc(sizeof(IsoImageWriter));
writer = calloc(1, sizeof(IsoImageWriter));
if (writer == NULL) {
return ISO_OUT_OF_MEM;
}