Browse code

cab related bug fixed, works now

aCaB authored on 2009/07/15 03:28:55
Showing 1 changed files
... ...
@@ -360,6 +360,7 @@ int cli_scanishield(int desc, cli_ctx *ctx, off_t off, size_t sz) {
360 360
 	    long cabno;
361 361
 	    if(!strcasecmp(fname + 4, "1.hdr")) {
362 362
 		if(c.hdr == -1) {
363
+		    cli_dbgmsg("ishield: added data1.hdr to array\n");
363 364
 		    c.hdr = coff;
364 365
 		    c.hdrsz = fsize;
365 366
 		    coff += fsize;
... ...
@@ -377,6 +378,7 @@ int cli_scanishield(int desc, cli_ctx *ctx, off_t off, size_t sz) {
377 377
 			ret = CL_EMEM;
378 378
 			break;
379 379
 		    }
380
+		    cli_dbgmsg("ishield: added data%lu.cab to array\n", cabno);
380 381
 		    c.cabs[i].cabno = cabno;
381 382
 		    c.cabs[i].off = coff;
382 383
 		    c.cabs[i].sz = fsize;
... ...
@@ -392,9 +394,12 @@ int cli_scanishield(int desc, cli_ctx *ctx, off_t off, size_t sz) {
392 392
     }
393 393
 
394 394
     if(ret == CL_CLEAN && (c.cabcnt || c.hdr != -1)) {
395
-	if(is_parse_hdr(desc, ctx, &c) == CL_CLEAN /* FIXMEISHIELD */) {
395
+	if(is_parse_hdr(desc, ctx, &c) == CL_CLEAN /* FIXMEISHIELD: return something and avoid scanning */) {
396 396
 	    unsigned int i;
397
-	    if(c.hdr != -1) ret = is_dump_and_scan(desc, ctx, c.hdr, c.hdrsz);
397
+	    if(c.hdr != -1) {
398
+		cli_errmsg("ishield: scanning data1.hdr\n");
399
+		ret = is_dump_and_scan(desc, ctx, c.hdr, c.hdrsz);
400
+	    }
398 401
 	    for(i=0; i<c.cabcnt && ret == CL_CLEAN; i++) {
399 402
 		cli_errmsg("ishield: scanning data%u.cab\n", c.cabs[i].cabno);
400 403
 		ret = is_dump_and_scan(desc, ctx, c.cabs[i].off, c.cabs[i].sz);
... ...
@@ -581,20 +586,24 @@ static int is_parse_hdr(int desc, cli_ctx *ctx, struct IS_CABSTUFF *c) { /* FIXM
581 581
 		    cli_errmsg("is_parse_hdr: not scanned (dup)\n");
582 582
 		else {
583 583
 		    if(file->size) { /* FIXMEISHIELD: limits */
584
-			unsigned int cab;
584
+			unsigned int j;
585 585
 			
586 586
 			int ret;
587
-			for(cab=0; cab<c->cabcnt && c->cabs[cab].cabno != cabno; cab++) {}
588
-			if(cab != cab<c->cabcnt) {
589
-/* 			    if(CLI_ISCONTAINED(c->cabs[cab].off, c->cabs[cab].sz, file_stream_off + c->cabs[cab].off, file_csize + c->cabs[cab].off)) */
590
-				ret = is_extract_cab(desc, ctx, file_stream_off + c->cabs[cab].off, file_size, file_csize);
591
-/* 			    else */
592
-/* 				cli_dbgmsg("is_parse_hdr: stream out of file\n"); */
587
+			for(j=0; j<c->cabcnt && c->cabs[j].cabno != cabno; j++) {}
588
+			if(j != c->cabcnt) {
589
+ 			    if(CLI_ISCONTAINED(c->cabs[j].off, c->cabs[j].sz, file_stream_off + c->cabs[j].off, file_csize))
590
+				ret = is_extract_cab(desc, ctx, file_stream_off + c->cabs[j].off, file_size, file_csize);
591
+ 			    else
592
+ 				cli_dbgmsg("is_parse_hdr: stream out of file\n");
593
+			} else {
594
+			    cli_dbgmsg("is_parse_hdr: data%u.cab not available\n", cabno);
593 595
 			}
594 596
 			if(ret != CL_CLEAN) {
595 597
 			    free(hdr);
596 598
 			    return ret;
597 599
 			}
600
+		    } else {
601
+			cli_dbgmsg("is_parse_hdr: skipped empty file\n");
598 602
 		    }
599 603
 		}
600 604
 		break;