Browse code

sort of works but very buggy

aCaB authored on 2009/07/15 03:04:59
Showing 1 changed files
... ...
@@ -545,6 +545,8 @@ static int is_parse_hdr(int desc, cli_ctx *ctx, struct IS_CABSTUFF *c) { /* FIXM
545 545
 	    char *dir_name = "", *file_name = "";
546 546
 	    uint32_t dir_rel = h1_data_off + objs_dirs_off + 4 * le32_to_host(file->dir_id); /* rel off of dir entry from array of rel ptrs */
547 547
 	    uint32_t file_rel = objs_dirs_off + h1_data_off + le32_to_host(file->str_name_off); /* rel off of fname */
548
+	    uint64_t file_stream_off, file_size, file_csize;
549
+	    uint16_t cabno;
548 550
 
549 551
 	    memcpy(hash, file->md5, 16);
550 552
 	    md5str((uint8_t *)hash);
... ...
@@ -556,25 +558,39 @@ static int is_parse_hdr(int desc, cli_ctx *ctx, struct IS_CABSTUFF *c) { /* FIXM
556 556
 	    if(CLI_ISCONTAINED(hdr, c->hdrsz, &hdr[file_rel], 1) && memchr(&hdr[file_rel], 0, c->hdrsz - file_rel))
557 557
 		file_name = &hdr[file_rel];
558 558
 		
559
+	    file_stream_off = le64_to_host(file->stream_off);
560
+	    file_size = le64_to_host(file->size);
561
+	    file_csize = le64_to_host(file->csize);
562
+	    cabno = le16_to_host(file->datafile_id);
563
+
559 564
 	    switch(file->flags) {
560 565
 	    case 0:
561 566
 		/* FIXMEISHIELD: for FS scan ? */
562 567
 		cli_errmsg("is_parse_hdr: skipped external file:%s\\%s (size: %llu csize: %llu md5:%s)\n",
563 568
 			   dir_name,
564 569
 			   file_name,
565
-			   le64_to_host(file->size), le64_to_host(file->csize), hash);
570
+			   file_size, file_csize, hash);
566 571
 		break;
567 572
 	    case 4:
568 573
 		cli_errmsg("is_parse_hdr: file %s\\%s (size: %llu csize: %llu md5:%s offset:%llx (data%u.cab) 13:%x 14:%x 15:%x)\n",
569 574
 			   dir_name,
570 575
 			   file_name,
571
-			   le64_to_host(file->size), le64_to_host(file->csize), hash, le64_to_host(file->stream_off),
572
-			   le16_to_host(file->datafile_id), file->unk13,  file->unk14,  file->unk15);
576
+			   file_size, file_csize, hash, file_stream_off,
577
+			   cabno, file->unk13,  file->unk14,  file->unk15);
573 578
 		if(file->flag_has_dup & 1)
574 579
 		    cli_errmsg("is_parse_hdr: not scanned (dup)\n");
575 580
 		else {
576 581
 		    if(file->size) { /* FIXMEISHIELD: limits */
577
-			int ret = is_extract_cab(desc, ctx, le64_to_host(file->stream_off), le64_to_host(file->size), le64_to_host(file->csize));
582
+			unsigned int cab;
583
+			
584
+			int ret;
585
+			for(cab=0; cab<c->cabcnt && c->cabs[cab].cabno != cabno; cab++) {}
586
+			if(cab != cab<c->cabcnt) {
587
+/* 			    if(CLI_ISCONTAINED(c->cabs[cab].off, c->cabs[cab].sz, file_stream_off + c->cabs[cab].off, file_csize + c->cabs[cab].off)) */
588
+				ret = is_extract_cab(desc, ctx, file_stream_off + c->cabs[cab].off, file_size, file_csize);
589
+/* 			    else */
590
+/* 				cli_dbgmsg("is_parse_hdr: stream out of file\n"); */
591
+			}
578 592
 			if(ret != CL_CLEAN) {
579 593
 			    free(hdr);
580 594
 			    return ret;