Better reaction wich -check_md5 if no MD5 array is loaded

This commit is contained in:
2009-08-13 20:36:21 +00:00
parent 14b101feef
commit 9a96860bad
4 changed files with 83 additions and 28 deletions

View File

@ -1116,7 +1116,8 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
goto ex;
ext= isoburn_ropt_noiso1999;
if((xorriso->ino_behavior & (1 | 2)) && !(xorriso->do_aaip & (1 | 4 | 32)))
if((xorriso->ino_behavior & (1 | 2)) && !(xorriso->do_aaip & (1 | 4 | 32))
&& !(xorriso->do_md5 & 1))
ext|= isoburn_ropt_noaaip;
if(!(xorriso->do_aaip & 1))
ext|= isoburn_ropt_noacl;
@ -7606,6 +7607,8 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
xorriso->find_check_md5_result|= 1;
else if(ret < 0)
xorriso->find_check_md5_result|= 2;
else if(ret == 1)
xorriso->find_check_md5_result|= 8;
else if(ret == 2)
xorriso->find_check_md5_result|= 4;
if(ret >= 0)
@ -8882,6 +8885,7 @@ int Xorriso_get_profile(struct XorrisO *xorriso, int *profile_number,
}
int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname,
void *node_pt, void **stream, int flag)
{
@ -8889,7 +8893,7 @@ int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname,
char eff_path[SfileadrL];
IsoNode *node= NULL;
IsoFile *filenode= NULL;
IsoStream *iso_stream= NULL;
IsoStream *iso_stream= NULL, *input_stream;
*stream= NULL;
if(flag&1) {
@ -8915,6 +8919,15 @@ int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname,
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
if(flag & 2) {
/* Dig out the most original stream */
while(1) {
input_stream= iso_stream_get_input_stream(iso_stream, 0);
if(input_stream == NULL)
break;
iso_stream= input_stream;
}
}
if(!iso_stream_is_repeatable(iso_stream)) {
sprintf(xorriso->info_text,
"The data production of the file in the image is one-time only");
@ -12154,13 +12167,13 @@ int Xorriso_check_md5(struct XorrisO *xorriso, void *in_node, char *path,
}
/* Read file and compute MD5 */;
ret= Xorriso_iso_file_open(xorriso, path, (void *) node, &stream, 1);
ret= Xorriso_iso_file_open(xorriso, path, (void *) node, &stream, 1 | 2);
if(ret <= 0)
{ret= -1; goto ex;}
ret= iso_md5_start(&ctx);
if(ret < 0)
goto ex;
todo= iso_file_get_size(file);
todo= iso_stream_get_size(stream);
while(todo > 0) {
if(todo < sizeof(buffer))
wanted= todo;
@ -12279,26 +12292,46 @@ int Xorriso_check_session_md5(struct XorrisO *xorriso, char *severity,
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
return(0);
}
sprintf(xorriso->info_text, "Checking loaded session by its recorded MD5.\n");
Xorriso_info(xorriso, 0);
for(i= 0; i < 16; i++)
sprintf(md5_text + 2 * i, "%2.2x", ((unsigned char *) md5)[i]);
sprintf(xorriso->info_text,
sprintf(xorriso->result_line,
"Session MD5 %s , LBA %.f , %.f blocks\n",
md5_text, (double) start_lba, (double) end_lba - start_lba);
Xorriso_info(xorriso, 0);
Xorriso_result(xorriso,0);
ret= Xorriso_check_md5_range(xorriso, (off_t) start_lba, (off_t) end_lba,
md5, 0);
if(ret <= 0) {
sprintf(xorriso->result_line, "MD5 MISMATCH WITH DATA OF LOADED SESSION\n");
sprintf(xorriso->result_line,
"MD5 MISMATCH WITH DATA OF LOADED SESSION !\n");
Xorriso_result(xorriso,0);
if(strcmp(severity, "ALL") != 0) {
sprintf(xorriso->info_text, "Event triggered by MD5 comparison mismatch");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, severity, 0);
}
} else {
sprintf(xorriso->result_line, "md5 of session data matches recorded md5\n");
sprintf(xorriso->result_line, "Ok, session data match recorded md5.\n");
Xorriso_result(xorriso,0);
}
return(ret);
}
int Xorriso_image_has_md5(struct XorrisO *xorriso, int flag)
{
int ret;
IsoImage *image;
uint32_t start_lba, end_lba;
char md5[16];
ret= Xorriso_get_volume(xorriso, &image, 0);
if(ret<=0)
return(ret);
ret= iso_image_get_session_md5(image, &start_lba, &end_lba, md5, 0);
Xorriso_process_msg_queues(xorriso,0);
if(ret <= 0)
return(ret);
return(1);
}