Fix new bug introduced when fixing previous bug.

This commit is contained in:
Vreixo Formoso 2008-02-08 22:32:33 +01:00
parent b501546627
commit e6593c9738
2 changed files with 6 additions and 4 deletions

View File

@ -243,6 +243,7 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
Ecma119Image *t; Ecma119Image *t;
IsoFileSrc *file; IsoFileSrc *file;
IsoFileSrc **filelist; IsoFileSrc **filelist;
char *name;
char buffer[BLOCK_SIZE]; char buffer[BLOCK_SIZE];
if (writer == NULL) { if (writer == NULL) {
@ -265,12 +266,12 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
uint32_t nblocks = DIV_UP(iso_file_src_get_size(file), BLOCK_SIZE); uint32_t nblocks = DIV_UP(iso_file_src_get_size(file), BLOCK_SIZE);
res = filesrc_open(file); res = filesrc_open(file);
name = iso_stream_get_name(file->stream);
if (res < 0) { if (res < 0) {
/* /*
* UPS, very ugly error, the best we can do is just to write * UPS, very ugly error, the best we can do is just to write
* 0's to image * 0's to image
*/ */
char *name = iso_stream_get_name(file->stream);
res = iso_msg_submit(t->image->id, ISO_FILE_CANT_WRITE, res, res = iso_msg_submit(t->image->id, ISO_FILE_CANT_WRITE, res,
"File \"%s\" can't be opened. Filling with 0s.", name); "File \"%s\" can't be opened. Filling with 0s.", name);
free(name); free(name);
@ -287,7 +288,6 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
} }
continue; continue;
} else if (res > 1) { } else if (res > 1) {
char *name = iso_stream_get_name(file->stream);
res = iso_msg_submit(t->image->id, ISO_FILE_CANT_WRITE, 0, res = iso_msg_submit(t->image->id, ISO_FILE_CANT_WRITE, 0,
"Size of file \"%s\" has changed. It will be %s", name, "Size of file \"%s\" has changed. It will be %s", name,
(res == 2 ? "truncated" : "padded with 0's")); (res == 2 ? "truncated" : "padded with 0's"));
@ -297,12 +297,14 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
return res; /* aborted due to error severity */ return res; /* aborted due to error severity */
} }
} }
iso_msg_debug(t->image->id, "Writing file %s", name);
free(name);
/* write file contents to image */ /* write file contents to image */
for (b = 0; b < nblocks; ++b) { for (b = 0; b < nblocks; ++b) {
int wres; int wres;
res = filesrc_read(file, buffer, BLOCK_SIZE); res = filesrc_read(file, buffer, BLOCK_SIZE);
if (res <= 0) { if (res < 0) {
/* read error */ /* read error */
break; break;
} }

View File

@ -620,7 +620,7 @@ int ifs_read(IsoFileSource *src, void *buf, size_t count)
/* how much can I read */ /* how much can I read */
bytes = MIN(BLOCK_SIZE - (data->data.offset % BLOCK_SIZE), bytes = MIN(BLOCK_SIZE - (data->data.offset % BLOCK_SIZE),
count - read); count - read);
if (data->data.offset + (off_t)bytes > data->info.st_size) { if (data->data.offset + (off_t)bytes > data->info.st_size) {
bytes = data->info.st_size - data->data.offset; bytes = data->info.st_size - data->data.offset;
} }
orig = data->data.content; orig = data->data.content;