Fix integer overflow in progress count.

This commit is contained in:
Vreixo Formoso 2007-12-29 22:21:11 +01:00
parent 7e66fe43ce
commit d9c9aea0c5

View File

@ -964,15 +964,17 @@ int iso_write(Ecma119Image *target, void *buf, size_t count)
return ISO_WRITE_ERROR; return ISO_WRITE_ERROR;
} }
if (ret > 0){
unsigned int kbw = (unsigned int) target->bytes_written >> 10;
unsigned int kbt = (unsigned int) target->total_size >> 10;
int percent = (kbw * 100) / kbt;
target->bytes_written += count; target->bytes_written += count;
{
int percent = (target->bytes_written * 100) / target->total_size;
/* only report in 5% chunks */ /* only report in 5% chunks */
if (percent >= target->percent_written + 5) { if (percent >= target->percent_written + 5) {
iso_msg_debug(target->image, "Processed %u of %u KB (%d %%)", iso_msg_debug(target->image, "Processed %u of %u KB (%d %%)",
(unsigned int) target->bytes_written >> 10, kbw, kbt, percent);
(unsigned int) target->total_size >> 10, percent);
target->percent_written = percent; target->percent_written = percent;
} }
} }