Throw error if imported_iso interval would be overwritten by multi-session

This commit is contained in:
Thomas Schmitt 2017-08-26 11:47:14 +02:00
parent cace41ec16
commit 028f9275d3
4 changed files with 17 additions and 5 deletions

View File

@ -2013,12 +2013,11 @@ int iso_interval_reader_keep(Ecma119Image *target,
if (!target->opts->appendable)
return 0;
/* --- From here on return either 1 or <0 --- */
/* multi-session write offset must be larger than interval end */
if (target->opts->ms_block <= ivr->end_byte / BLOCK_SIZE)
/* >>> ??? return error ??? */
return 0;
return ISO_MULTI_OVER_IMPORTED;
return 1;
}
@ -2036,6 +2035,8 @@ int iso_interval_reader_start_size(Ecma119Image *t, char *path,
return ret;
*start_byte = ivr->start_byte;
keep = iso_interval_reader_keep(t, ivr, 0);
if (keep < 0)
return(keep);
iso_interval_reader_destroy(&ivr, 0);
return ISO_SUCCESS + (keep > 0);
}
@ -2066,7 +2067,10 @@ int iso_write_partition_file(Ecma119Image *target, char *path,
&ivr, &byte_count, 0);
if (ret < 0)
goto ex;
if (iso_interval_reader_keep(target, ivr, 0)) {
ret = iso_interval_reader_keep(target, ivr, 0);
if (ret < 0)
goto ex;
if (ret > 0) {
/* From imported_iso and for add-on session. Leave it in place. */
ret = ISO_SUCCESS;
goto ex;

View File

@ -8887,6 +8887,10 @@ int iso_conv_name_chars(IsoWriteOpts *opts, char *name, size_t name_len,
(FAILURE, HIGH, -419) */
#define ISO_SUSP_WRONG_CE_SIZE 0xE830FE5D
/** Multi-session would overwrite imported_iso interval
(FAILURE, HIGH, -420) */
#define ISO_MULTI_OVER_IMPORTED 0xE830FE5C
/* Internal developer note:
Place new error codes directly above this comment.

View File

@ -551,6 +551,8 @@ const char *iso_error_to_msg(int errcode)
return "Unable to obtain root directory";
case ISO_SUSP_WRONG_CE_SIZE:
return "Zero sized, oversized, or mislocated SUSP CE area found";
case ISO_MULTI_OVER_IMPORTED:
return "Multi-session would overwrite imported_iso interval";
default:
return "Unknown error";
}

View File

@ -129,6 +129,8 @@ static int compute_partition_size(Ecma119Image *t, char *disk_path,
*size = (byte_count + BLOCK_SIZE - 1) / BLOCK_SIZE;
keep = iso_interval_reader_keep(t, ivr, 0);
iso_interval_reader_destroy(&ivr, 0);
if (keep < 0)
return keep;
return ISO_SUCCESS + (keep > 0);
}