diff --git a/xorriso/findjob.c b/xorriso/findjob.c index f5297805..adb432d8 100644 --- a/xorriso/findjob.c +++ b/xorriso/findjob.c @@ -917,16 +917,39 @@ int Findjob_set_size_filter(struct FindjoB *o, int test_type, } -int Findjob_set_lba_range(struct FindjoB *o, int start_lba, int count, +int Findjob_set_off_t_filter(struct FindjoB *o, int test_type, + off_t num1, off_t num2, int flag) +{ + struct ExprtesT *t; + int ret; + + ret= Findjob_default_and(o, 0); + if(ret <= 0) + return(ret); + + t= o->cursor->test; + t->test_type= test_type; + t->arg1= calloc(sizeof(off_t), 1); + t->arg2= calloc(sizeof(off_t), 1); + if(t->arg1 == NULL || t->arg2 == NULL) + return(-1); + *((off_t *) t->arg1)= num1; + *((off_t *) t->arg2)= num2; + return(1); +} + + +int Findjob_set_lba_range(struct FindjoB *o, off_t start_lba, off_t count, int flag) { - int ret, end_lba; + int ret; + off_t end_lba; if(start_lba > 0) end_lba= start_lba + count - 1; else end_lba= start_lba - count + 1; - ret= Findjob_set_num_filter(o, 4, start_lba, end_lba, 0); + ret= Findjob_set_off_t_filter(o, 4, start_lba, end_lba, 0); return(ret); } diff --git a/xorriso/findjob.h b/xorriso/findjob.h index eac0a851..fe889a21 100644 --- a/xorriso/findjob.h +++ b/xorriso/findjob.h @@ -32,7 +32,7 @@ struct ExprtesT { 1= -name char *arg1 (regex_t in *arg2) 2= -type char *arg1 3= -damaged - 4= -lba_range int *arg1 int *arg2 + 4= -lba_range off_t *arg1 off_t *arg2 5= -has_acl 6= -has_xattr 7= -has_aaip @@ -250,7 +250,10 @@ int Findjob_set_num_filter(struct FindjoB *o, int test_type, int Findjob_set_size_filter(struct FindjoB *o, int test_type, off_t num1, int num2, int flag); -int Findjob_set_lba_range(struct FindjoB *o, int start_lba, int count, +int Findjob_set_off_t_filter(struct FindjoB *o, int test_type, + off_t num1, off_t num2, int flag); + +int Findjob_set_lba_range(struct FindjoB *o, off_t start_lba, off_t count, int flag); int Findjob_set_wanted_node(struct FindjoB *o, void *wanted_node, int flag); diff --git a/xorriso/iso_manip.c b/xorriso/iso_manip.c index ede9942e..e019f05b 100644 --- a/xorriso/iso_manip.c +++ b/xorriso/iso_manip.c @@ -3055,7 +3055,8 @@ return: 3 = immediate decision : does match */ { - int value=0, ret, start_lba, end_lba, bless_idx, size_mode; + int value=0, ret, start_lba, bless_idx, size_mode; + off_t range_lba, end_lba; int lba_count, *file_end_lbas= NULL, *file_start_lbas= NULL, i, mask; void *arg1, *arg2; char ft, *decision, md5[16], bless_code[17]; @@ -3146,10 +3147,10 @@ return: break; case 4: /* -lba_range *arg1 *arg2 */ value= 1; - start_lba= *((int *) ftest->arg1); - end_lba= *((int *) ftest->arg2); + range_lba= *((off_t *) ftest->arg1); + end_lba= *((off_t *) ftest->arg2); if(node == NULL) { - value= !(start_lba >= 0); + value= !(range_lba >= 0); goto ex; } ret= Xorriso__start_end_lbas(node, &lba_count, &file_start_lbas, @@ -3157,15 +3158,15 @@ return: if(ret <= 0) { if(ret < 0) Xorriso_process_msg_queues(xorriso, 0); - if(start_lba >= 0) + if(range_lba >= 0) value= 0; } else { for(i= 0; i < lba_count; i++) { - if(start_lba >= 0) { - if(file_end_lbas[i] < start_lba || file_start_lbas[i] > end_lba) + if(range_lba >= 0) { + if(file_end_lbas[i] < range_lba || file_start_lbas[i] > end_lba) value= 0; } else { - if(file_end_lbas[i] >= -start_lba && file_start_lbas[i] <= -end_lba) + if(file_end_lbas[i] >= -range_lba && file_start_lbas[i] <= -end_lba) value= 0; } } diff --git a/xorriso/iso_tree.c b/xorriso/iso_tree.c index d488a025..068494ae 100644 --- a/xorriso/iso_tree.c +++ b/xorriso/iso_tree.c @@ -477,7 +477,7 @@ int Xorriso_path_from_lba(struct XorrisO *xorriso, IsoNode *node, int lba, return(ret); } if(flag & 1) - Findjob_set_lba_range(job, lba, 1, 0); + Findjob_set_lba_range(job, (off_t) lba, (off_t) 1, 0); else Findjob_set_wanted_node(job, (void *) node, 0); Findjob_set_action_found_path(job, 0); diff --git a/xorriso/opts_d_h.c b/xorriso/opts_d_h.c index e4aca4ff..c5c1b2c9 100644 --- a/xorriso/opts_d_h.c +++ b/xorriso/opts_d_h.c @@ -835,7 +835,8 @@ static int Xorriso_truncate_const_find_name(struct XorrisO *xorriso, int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv, int *idx, int flag) { - int ret, i, end_idx, type= 0, action, deleter= 0, start_lba, count; + int ret, i, end_idx, type= 0, action, deleter= 0, count; + off_t start_lba, block_count; int list_extattr_head= 0, bsl_mem, disk_path, name_space, prefix_code; struct FindjoB *job, *first_job= NULL, *new_job; char *start_path, *path= NULL, *cpt, *other_path_start= NULL, *cd_pt; @@ -919,9 +920,16 @@ not_enough_arguments:; i+= 2; /* >>> if letter suffix: use Scanf_io_size */ - sscanf(argv[i-1], "%d", &start_lba); - sscanf(argv[i], "%d", &count); - Findjob_set_lba_range(job, start_lba, count, 0); + ret= Sfile_text_to_off_t(argv[i - 1], &start_lba, 0); + if(ret <= 0) { +off_t_overflow:; + sprintf(xorriso->info_text, "-find[ix]: -lba_range number too large"); + goto sorry_ex; + } + ret= Sfile_text_to_off_t(argv[i], &block_count, 0); + if(ret <= 0) + goto off_t_overflow; + Findjob_set_lba_range(job, start_lba, block_count, 0); } else if(strcmp(argv[i], "-pending_data")==0) { Findjob_set_commit_filter_2(job, 0); } else if(strcmp(argv[i], "-has_acl")==0) { diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index e2a391a2..770d1292 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2024.03.20.114449" +#define Xorriso_timestamP "2024.03.20.150514"