Made struct xorriso_md5_state ready for long block addresses

This commit is contained in:
Thomas Schmitt 2024-03-28 15:51:52 +01:00
parent 14676ef132
commit 4fe385baed
2 changed files with 36 additions and 25 deletions

View File

@ -2547,13 +2547,13 @@ struct xorriso_md5_state {
pthread_mutex_t spot_mutex; pthread_mutex_t spot_mutex;
/* Checksum tag cursor */ /* Checksum tag cursor */
uint32_t md5_start; off_t md5_start;
uint32_t next_tag; off_t next_tag;
int chain_broken; int chain_broken;
int in_track_gap; int in_track_gap;
int was_sb_tag; int was_sb_tag;
int md5_spot_value; int md5_spot_value;
uint32_t md5_spot_lba; off_t md5_spot_lba;
/* Asynchronous operation */ /* Asynchronous operation */
@ -2572,7 +2572,7 @@ struct xorriso_md5_state {
3= end-of-processing (set by boss when done) 3= end-of-processing (set by boss when done)
*/ */
int *chunk_fill; /* Actual number of valid bytes in chunk */ int *chunk_fill; /* Actual number of valid bytes in chunk */
uint32_t *chunk_lba; off_t *chunk_lba;
int chunk_w_idx; /* Write index. Operated by boss */ int chunk_w_idx; /* Write index. Operated by boss */
int chunk_r_idx; /* Read index. Operated by MD5 slave */ int chunk_r_idx; /* Read index. Operated by MD5 slave */
@ -2604,16 +2604,25 @@ int Xorriso__add_spot(struct xorriso_md5_state *state,
int Xorriso_chunk_md5(struct XorrisO *xorriso, char *data, int to_read, int Xorriso_chunk_md5(struct XorrisO *xorriso, char *data, int to_read,
uint32_t from_lba, struct xorriso_md5_state *state, int flag) off_t from_lba, struct xorriso_md5_state *state, int flag)
{ {
int j, k, ret= 0, valid, tag_type, decode_ret= 0; int j, k, ret= 0, valid, tag_type, decode_ret= 0;
uint32_t lba, pos, range_start, range_size; uint32_t pos, range_start, range_size, next_tag_uint32;
off_t lba;
char md5[16], tag_md5[16], *tag_type_name= "", *comparison, *sev_text; char md5[16], tag_md5[16], *tag_type_name= "", *comparison, *sev_text;
char md5_text[33]; char md5_text[33];
void *cloned_ctx= NULL; void *cloned_ctx= NULL;
for(j= 0; j < to_read; j++) { for(j= 0; j < to_read; j++) {
lba= j + from_lba; lba= j + from_lba;
if(lba > (off_t) 0xffffffff) {
if(lba == (off_t) 0x100000000) {
printf(xorriso->info_text,
"Checkreading exceeds the 32-bit block address limit of libisofs MD5 tags");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING",0);
}
break;
}
if(lba < state->md5_start) if(lba < state->md5_start)
continue; continue;
ret= decode_ret= 0; ret= decode_ret= 0;
@ -2621,8 +2630,10 @@ int Xorriso_chunk_md5(struct XorrisO *xorriso, char *data, int to_read,
(state->next_tag == 0 || state->chain_broken || lba == state->next_tag)){ (state->next_tag == 0 || state->chain_broken || lba == state->next_tag)){
ret= iso_util_decode_md5_tag(data + j * 2048, &tag_type, ret= iso_util_decode_md5_tag(data + j * 2048, &tag_type,
&pos, &range_start, &range_size, &pos, &range_start, &range_size,
&(state->next_tag), tag_md5, &next_tag_uint32, tag_md5,
!!state->chain_broken); !!state->chain_broken);
if(ret > 0 && tag_type >= 2 && tag_type <= 4)
state->next_tag= next_tag_uint32;
decode_ret= ret; decode_ret= ret;
} }
valid= (ret == 1 || ret == (int) ISO_MD5_AREA_CORRUPTED) && pos == lba; valid= (ret == 1 || ret == (int) ISO_MD5_AREA_CORRUPTED) && pos == lba;
@ -2643,7 +2654,7 @@ int Xorriso_chunk_md5(struct XorrisO *xorriso, char *data, int to_read,
ret= -1; goto ex; ret= -1; goto ex;
} }
iso_md5_compute(&(state->ctx), data + (j - (lba - range_start)) * 2048, iso_md5_compute(&(state->ctx), data + (j - (lba - range_start)) * 2048,
(lba - range_start) * 2048); (int) (lba - range_start) * 2048);
state->md5_start= range_start; state->md5_start= range_start;
state->in_track_gap= 0; state->in_track_gap= 0;
} }
@ -2662,13 +2673,13 @@ int Xorriso_chunk_md5(struct XorrisO *xorriso, char *data, int to_read,
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"Found MD5 %s tag which covers different data range", tag_type_name); "Found MD5 %s tag which covers different data range", tag_type_name);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE",0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE",0);
sprintf(xorriso->info_text, " Expected start: %u Found: %u", sprintf(xorriso->info_text, " Expected start: %.f Found: %lu",
(unsigned int) state->md5_start, range_start); (double) state->md5_start, (unsigned long int) range_start);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE",0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE",0);
for(k= 0; k < 16; k++) for(k= 0; k < 16; k++)
sprintf(md5_text + 2 * k, "%2.2x", ((unsigned char *) tag_md5)[k]); sprintf(md5_text + 2 * k, "%2.2x", ((unsigned char *) tag_md5)[k]);
sprintf(xorriso->info_text, " Size: %u MD5: %s", sprintf(xorriso->info_text, " Size: %lu MD5: %s",
range_size, md5_text); (unsigned long int) range_size, md5_text);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE",0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE",0);
state->chain_broken= 1; state->chain_broken= 1;
valid= 0; valid= 0;
@ -2697,15 +2708,15 @@ int Xorriso_chunk_md5(struct XorrisO *xorriso, char *data, int to_read,
} }
state->md5_spot_lba= lba; state->md5_spot_lba= lba;
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"Found %s MD5 %s tag: start=%d size=%d", "Found %s MD5 %s tag: start=%.f size=%.f",
comparison, tag_type_name, state->md5_start, comparison, tag_type_name, (double) state->md5_start,
lba - state->md5_start); (double) (lba - state->md5_start));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, sev_text, 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, sev_text, 0);
} }
if(valid && (tag_type == 1 || (tag_type == 4 && pos == lba && lba < 32))){ if(valid && (tag_type == 1 || (tag_type == 4 && pos == lba && lba < 32))){
if(state->md5_spot_value != Xorriso_read_quality_untesteD) { if(state->md5_spot_value != Xorriso_read_quality_untesteD) {
ret= Xorriso__add_spot(state, (off_t) state->md5_start, ret= Xorriso__add_spot(state, state->md5_start,
(off_t) state->md5_spot_lba - state->md5_start, state->md5_spot_lba - state->md5_start,
state->md5_spot_value, 0); state->md5_spot_value, 0);
if(ret <= 0) if(ret <= 0)
goto ex; goto ex;
@ -2964,7 +2975,7 @@ int Xorriso_check_interval(struct XorrisO *xorriso, struct SpotlisT *spotlist,
Xorriso_alloc_meM(state.chunk, char *, num_chunks); Xorriso_alloc_meM(state.chunk, char *, num_chunks);
Xorriso_alloc_meM(state.chunk_state, int, num_chunks); Xorriso_alloc_meM(state.chunk_state, int, num_chunks);
Xorriso_alloc_meM(state.chunk_fill, int, num_chunks); Xorriso_alloc_meM(state.chunk_fill, int, num_chunks);
Xorriso_alloc_meM(state.chunk_lba, uint32_t, num_chunks); Xorriso_alloc_meM(state.chunk_lba, off_t, num_chunks);
for(i= 0; i < state.num_chunks; i++) { for(i= 0; i < state.num_chunks; i++) {
state.chunk[i]= data + read_chunk * i * 2048; state.chunk[i]= data + read_chunk * i * 2048;
state.chunk_state[i]= 0; state.chunk_state[i]= 0;
@ -3143,7 +3154,7 @@ abort_check:;
state.chunk_w_idx= (state.chunk_w_idx + 1) % state.num_chunks; state.chunk_w_idx= (state.chunk_w_idx + 1) % state.num_chunks;
} else { } else {
ret= Xorriso_chunk_md5(xorriso, data_pt, to_read, ret= Xorriso_chunk_md5(xorriso, data_pt, to_read,
(uint32_t) (i + from_lba), &state, 0); i + from_lba, &state, 0);
if(ret <= 0) if(ret <= 0)
goto ex; goto ex;
} }
@ -3232,15 +3243,15 @@ failed_to_write:;
/* >>> ??? allow chain_broken to be a match ? */ /* >>> ??? allow chain_broken to be a match ? */
if(state.next_tag > 0) { if(state.next_tag > 0) {
sprintf(xorriso->info_text, "Missing announced MD5 tag: start=%d pos=%d", sprintf(xorriso->info_text, "Missing announced MD5 tag: start=%.f pos=%.f",
state.md5_start, state.next_tag); (double) state.md5_start, (double) state.next_tag);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
state.md5_spot_value= Xorriso_read_quality_md5_mismatcH; state.md5_spot_value= Xorriso_read_quality_md5_mismatcH;
state.md5_spot_lba= state.next_tag; state.md5_spot_lba= state.next_tag;
} }
if(state.md5_spot_value != Xorriso_read_quality_untesteD) { if(state.md5_spot_value != Xorriso_read_quality_untesteD) {
ret= Xorriso__add_spot(&state, (off_t) state.md5_start, ret= Xorriso__add_spot(&state, state.md5_start,
(off_t) (state.md5_spot_lba - state.md5_start), state.md5_spot_lba - state.md5_start,
state.md5_spot_value, 0); state.md5_spot_value, 0);
if(ret <= 0) if(ret <= 0)
goto ex; goto ex;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2024.03.24.085148" #define Xorriso_timestamP "2024.03.28.144046"