git-svn: trunk@3541
Tomasz Kojm authored on 2008/01/25 21:03:25... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Fri Jan 25 12:43:30 CET 2008 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * libclamav/cab.c: improve performance of cabinet extractor (bb#730) |
|
4 |
+ |
|
1 | 5 |
Fri Jan 25 10:14:23 EET 2008 (edwin) |
2 | 6 |
------------------------------------ |
3 | 7 |
* libclamav/entconv.[ch]: make iconv replacement function handle NULL args |
... | ... |
@@ -634,24 +634,23 @@ int cab_extract(struct cab_file *file, const char *name) |
634 | 634 |
close(file->ofd); |
635 | 635 |
return CL_EMSCAB; |
636 | 636 |
} |
637 |
- if(file->offset > 0) { |
|
637 |
+ ret = mszip_decompress(file->state->stream, file->length); |
|
638 |
+ mszip_free(file->state->stream); |
|
639 |
+ if(ret < 0 && file->offset > 0) { |
|
640 |
+ memset(file->state, 0, sizeof(struct cab_state)); |
|
641 |
+ file->state->stream = (struct mszip_stream *) mszip_init(file->fd, file->ofd, 4096, 1, file, &cab_read); |
|
642 |
+ if(!file->state->stream) { |
|
643 |
+ free(file->state); |
|
644 |
+ close(file->ofd); |
|
645 |
+ return CL_EMSCAB; |
|
646 |
+ } |
|
638 | 647 |
((struct mszip_stream *) file->state->stream)->wflag = 0; |
639 |
- ret = mszip_decompress(file->state->stream, file->offset); |
|
640 |
- ((struct mszip_stream *) file->state->stream)->wflag = 1; |
|
641 |
- if(ret < 0) { |
|
642 |
- mszip_free(file->state->stream); |
|
643 |
- memset(file->state, 0, sizeof(struct cab_state)); |
|
644 |
- file->state->stream = (struct mszip_stream *) mszip_init(file->fd, file->ofd, 4096, 1, file, &cab_read); |
|
645 |
- if(!file->state->stream) { |
|
646 |
- free(file->state); |
|
647 |
- close(file->ofd); |
|
648 |
- return CL_EMSCAB; |
|
649 |
- } |
|
650 |
- lseek(file->fd, file->folder->offset, SEEK_SET); |
|
648 |
+ if(mszip_decompress(file->state->stream, file->offset) == CL_SUCCESS) { |
|
649 |
+ ((struct mszip_stream *) file->state->stream)->wflag = 1; |
|
650 |
+ ret = mszip_decompress(file->state->stream, file->length); |
|
651 | 651 |
} |
652 |
+ mszip_free(file->state->stream); |
|
652 | 653 |
} |
653 |
- ret = mszip_decompress(file->state->stream, file->length); |
|
654 |
- mszip_free(file->state->stream); |
|
655 | 654 |
break; |
656 | 655 |
|
657 | 656 |
case 0x0002: /* QUANTUM */ |
... | ... |
@@ -662,13 +661,23 @@ int cab_extract(struct cab_file *file, const char *name) |
662 | 662 |
close(file->ofd); |
663 | 663 |
return CL_EMSCAB; |
664 | 664 |
} |
665 |
- if(file->offset > 0) { |
|
666 |
- ((struct qtm_stream *) file->state->stream)->wflag = 0; |
|
667 |
- qtm_decompress(file->state->stream, file->offset); |
|
668 |
- ((struct qtm_stream *) file->state->stream)->wflag = 1; |
|
669 |
- } |
|
670 | 665 |
ret = qtm_decompress(file->state->stream, file->length); |
671 | 666 |
qtm_free(file->state->stream); |
667 |
+ if(ret < 0 && file->offset > 0) { |
|
668 |
+ memset(file->state, 0, sizeof(struct cab_state)); |
|
669 |
+ file->state->stream = (struct qtm_stream *) qtm_init(file->fd, file->ofd, (int) (file->folder->cmethod >> 8) & 0x1f, 4096, file, &cab_read); |
|
670 |
+ if(!file->state->stream) { |
|
671 |
+ free(file->state); |
|
672 |
+ close(file->ofd); |
|
673 |
+ return CL_EMSCAB; |
|
674 |
+ } |
|
675 |
+ ((struct qtm_stream *) file->state->stream)->wflag = 0; |
|
676 |
+ if(qtm_decompress(file->state->stream, file->offset) == CL_SUCCESS) { |
|
677 |
+ ((struct qtm_stream *) file->state->stream)->wflag = 1; |
|
678 |
+ ret = qtm_decompress(file->state->stream, file->length); |
|
679 |
+ } |
|
680 |
+ qtm_free(file->state->stream); |
|
681 |
+ } |
|
672 | 682 |
break; |
673 | 683 |
|
674 | 684 |
case 0x0003: /* LZX */ |