New -osirrox option check_md5_on|_off|_force
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
|
||||
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
|
||||
|
||||
Copyright 2007-2019 Thomas Schmitt, <scdbackup@gmx.net>
|
||||
Copyright 2007-2020 Thomas Schmitt, <scdbackup@gmx.net>
|
||||
|
||||
Provided under GPL version 2 or later.
|
||||
|
||||
@ -565,10 +565,15 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
||||
uint32_t lba;
|
||||
char *catcontent = NULL;
|
||||
off_t catsize;
|
||||
char disk_md5[16], iso_md5[16];
|
||||
void *ctx= NULL;
|
||||
int use_md5= 0, i;
|
||||
|
||||
Xorriso_alloc_meM(buf, char, buf_size);
|
||||
Xorriso_alloc_meM(temp_path, char, SfileadrL);
|
||||
|
||||
if(!(flag & 2))
|
||||
img_offset= bytes= 0;
|
||||
if(LIBISO_ISDIR(node)) {
|
||||
what= "directory";
|
||||
ret= mkdir(disk_path, 0777);
|
||||
@ -583,6 +588,25 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
||||
1);
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
if((xorriso->do_md5 & 65) == 65 && !(flag & 2)) {
|
||||
ret= Xorriso_is_plain_image_file(xorriso, (void *) node, img_path, 0);
|
||||
if(ret > 0) {
|
||||
ret= Xorriso_get_md5(xorriso, (void *) node, img_path, iso_md5, 1);
|
||||
if(ret > 0)
|
||||
ret= Xorriso_md5_start(xorriso, &ctx, 0);
|
||||
if(ret > 0) {
|
||||
use_md5= 1;
|
||||
} else if(xorriso->do_md5 & 128) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Cannot obtain any recorded MD5 of file ");
|
||||
Text_shellsafe(img_path, xorriso->info_text, 1);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
||||
ret= Xorriso_eval_problem_status(xorriso, 0, 1 | 2);
|
||||
if(ret < 0)
|
||||
{ret= 0; goto ex;}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
open_path_pt= disk_path;
|
||||
ret= stat(open_path_pt, &stbuf);
|
||||
@ -696,6 +720,8 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
||||
break;
|
||||
}
|
||||
read_count+= ret;
|
||||
if(use_md5)
|
||||
Xorriso_md5_compute(xorriso, ctx, buf_pt, ret, 0);
|
||||
|
||||
if(img_offset > read_count - ret) {
|
||||
/* skip the desired amount of bytes */
|
||||
@ -724,7 +750,30 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(use_md5) {
|
||||
ret= Xorriso_md5_end(xorriso, &ctx, disk_md5, 0);
|
||||
if(ret <= 0) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Internal problem with obtaining computed MD5 for extracted data of ");
|
||||
goto bad_md5;
|
||||
} else {
|
||||
for(i= 0; i < 16; i++)
|
||||
if(iso_md5[i] != disk_md5[i])
|
||||
break;
|
||||
if(i < 16) {
|
||||
sprintf(xorriso->info_text,
|
||||
"MD5 of extracted data does not match recorded MD5 of file ");
|
||||
bad_md5:;
|
||||
Text_shellsafe(img_path, xorriso->info_text, 1);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
||||
ret= Xorriso_eval_problem_status(xorriso, 0, 1 | 2);
|
||||
if(ret < 0)
|
||||
{ret= 0; goto ex;}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(write_fd != -1)
|
||||
close(write_fd);
|
||||
write_fd= -1;
|
||||
@ -847,6 +896,8 @@ ex:;
|
||||
free(catcontent);
|
||||
if(data_stream!=NULL)
|
||||
Xorriso_iso_file_close(xorriso, &data_stream, 0);
|
||||
if(ctx != NULL)
|
||||
Xorriso_md5_end(xorriso, &ctx, disk_md5, 0);
|
||||
Xorriso_process_msg_queues(xorriso,0);
|
||||
return(ret);
|
||||
}
|
||||
|
Reference in New Issue
Block a user