|
Lines 574-581
int BZ_API(BZ2_bzDecompressInit)
Link Here
|
| 574 |
|
574 |
|
| 575 |
|
575 |
|
| 576 |
/*---------------------------------------------------*/ |
576 |
/*---------------------------------------------------*/ |
|
|
577 |
/* Return True iff data corruption is discovered. |
| 578 |
Returns False if there is no problem. |
| 579 |
*/ |
| 577 |
static |
580 |
static |
| 578 |
void unRLE_obuf_to_output_FAST ( DState* s ) |
581 |
Bool unRLE_obuf_to_output_FAST ( DState* s ) |
| 579 |
{ |
582 |
{ |
| 580 |
UChar k1; |
583 |
UChar k1; |
| 581 |
|
584 |
|
|
Lines 584-590
void unRLE_obuf_to_output_FAST ( DState*
Link Here
|
| 584 |
while (True) { |
587 |
while (True) { |
| 585 |
/* try to finish existing run */ |
588 |
/* try to finish existing run */ |
| 586 |
while (True) { |
589 |
while (True) { |
| 587 |
if (s->strm->avail_out == 0) return; |
590 |
if (s->strm->avail_out == 0) return False; |
| 588 |
if (s->state_out_len == 0) break; |
591 |
if (s->state_out_len == 0) break; |
| 589 |
*( (UChar*)(s->strm->next_out) ) = s->state_out_ch; |
592 |
*( (UChar*)(s->strm->next_out) ) = s->state_out_ch; |
| 590 |
BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); |
593 |
BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); |
|
Lines 594-603
void unRLE_obuf_to_output_FAST ( DState*
Link Here
|
| 594 |
s->strm->total_out_lo32++; |
597 |
s->strm->total_out_lo32++; |
| 595 |
if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; |
598 |
if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; |
| 596 |
} |
599 |
} |
| 597 |
|
600 |
|
| 598 |
/* can a new run be started? */ |
601 |
/* can a new run be started? */ |
| 599 |
if (s->nblock_used == s->save_nblock+1) return; |
602 |
if (s->nblock_used == s->save_nblock+1) return False; |
| 600 |
|
603 |
|
|
|
604 |
/* Only caused by corrupt data stream? */ |
| 605 |
if (s->nblock_used > s->save_nblock+1) |
| 606 |
return True; |
| 601 |
|
607 |
|
| 602 |
s->state_out_len = 1; |
608 |
s->state_out_len = 1; |
| 603 |
s->state_out_ch = s->k0; |
609 |
s->state_out_ch = s->k0; |
|
Lines 667-672
void unRLE_obuf_to_output_FAST ( DState*
Link Here
|
| 667 |
cs_avail_out--; |
673 |
cs_avail_out--; |
| 668 |
} |
674 |
} |
| 669 |
} |
675 |
} |
|
|
676 |
/* Only caused by corrupt data stream? */ |
| 677 |
if (c_nblock_used > s_save_nblockPP) |
| 678 |
return True; |
| 679 |
|
| 670 |
/* can a new run be started? */ |
680 |
/* can a new run be started? */ |
| 671 |
if (c_nblock_used == s_save_nblockPP) { |
681 |
if (c_nblock_used == s_save_nblockPP) { |
| 672 |
c_state_out_len = 0; goto return_notr; |
682 |
c_state_out_len = 0; goto return_notr; |
|
Lines 712-717
void unRLE_obuf_to_output_FAST ( DState*
Link Here
|
| 712 |
s->strm->avail_out = cs_avail_out; |
722 |
s->strm->avail_out = cs_avail_out; |
| 713 |
/* end save */ |
723 |
/* end save */ |
| 714 |
} |
724 |
} |
|
|
725 |
return False; |
| 715 |
} |
726 |
} |
| 716 |
|
727 |
|
| 717 |
|
728 |
|
|
Lines 732-739
__inline__ Int32 BZ2_indexIntoF ( Int32
Link Here
|
| 732 |
|
743 |
|
| 733 |
|
744 |
|
| 734 |
/*---------------------------------------------------*/ |
745 |
/*---------------------------------------------------*/ |
|
|
746 |
/* Return True iff data corruption is discovered. |
| 747 |
Returns False if there is no problem. |
| 748 |
*/ |
| 735 |
static |
749 |
static |
| 736 |
void unRLE_obuf_to_output_SMALL ( DState* s ) |
750 |
Bool unRLE_obuf_to_output_SMALL ( DState* s ) |
| 737 |
{ |
751 |
{ |
| 738 |
UChar k1; |
752 |
UChar k1; |
| 739 |
|
753 |
|
|
Lines 742-748
void unRLE_obuf_to_output_SMALL ( DState
Link Here
|
| 742 |
while (True) { |
756 |
while (True) { |
| 743 |
/* try to finish existing run */ |
757 |
/* try to finish existing run */ |
| 744 |
while (True) { |
758 |
while (True) { |
| 745 |
if (s->strm->avail_out == 0) return; |
759 |
if (s->strm->avail_out == 0) return False; |
| 746 |
if (s->state_out_len == 0) break; |
760 |
if (s->state_out_len == 0) break; |
| 747 |
*( (UChar*)(s->strm->next_out) ) = s->state_out_ch; |
761 |
*( (UChar*)(s->strm->next_out) ) = s->state_out_ch; |
| 748 |
BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); |
762 |
BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); |
|
Lines 754-761
void unRLE_obuf_to_output_SMALL ( DState
Link Here
|
| 754 |
} |
768 |
} |
| 755 |
|
769 |
|
| 756 |
/* can a new run be started? */ |
770 |
/* can a new run be started? */ |
| 757 |
if (s->nblock_used == s->save_nblock+1) return; |
771 |
if (s->nblock_used == s->save_nblock+1) return False; |
| 758 |
|
772 |
|
|
|
773 |
/* Only caused by corrupt data stream? */ |
| 774 |
if (s->nblock_used > s->save_nblock+1) |
| 775 |
return True; |
| 759 |
|
776 |
|
| 760 |
s->state_out_len = 1; |
777 |
s->state_out_len = 1; |
| 761 |
s->state_out_ch = s->k0; |
778 |
s->state_out_ch = s->k0; |
|
Lines 788-794
void unRLE_obuf_to_output_SMALL ( DState
Link Here
|
| 788 |
while (True) { |
805 |
while (True) { |
| 789 |
/* try to finish existing run */ |
806 |
/* try to finish existing run */ |
| 790 |
while (True) { |
807 |
while (True) { |
| 791 |
if (s->strm->avail_out == 0) return; |
808 |
if (s->strm->avail_out == 0) return False; |
| 792 |
if (s->state_out_len == 0) break; |
809 |
if (s->state_out_len == 0) break; |
| 793 |
*( (UChar*)(s->strm->next_out) ) = s->state_out_ch; |
810 |
*( (UChar*)(s->strm->next_out) ) = s->state_out_ch; |
| 794 |
BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); |
811 |
BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); |
|
Lines 800-806
void unRLE_obuf_to_output_SMALL ( DState
Link Here
|
| 800 |
} |
817 |
} |
| 801 |
|
818 |
|
| 802 |
/* can a new run be started? */ |
819 |
/* can a new run be started? */ |
| 803 |
if (s->nblock_used == s->save_nblock+1) return; |
820 |
if (s->nblock_used == s->save_nblock+1) return False; |
|
|
821 |
|
| 822 |
/* Only caused by corrupt data stream? */ |
| 823 |
if (s->nblock_used > s->save_nblock+1) |
| 824 |
return True; |
| 804 |
|
825 |
|
| 805 |
s->state_out_len = 1; |
826 |
s->state_out_len = 1; |
| 806 |
s->state_out_ch = s->k0; |
827 |
s->state_out_ch = s->k0; |
|
Lines 830-835
void unRLE_obuf_to_output_SMALL ( DState
Link Here
|
| 830 |
/*---------------------------------------------------*/ |
851 |
/*---------------------------------------------------*/ |
| 831 |
int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) |
852 |
int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) |
| 832 |
{ |
853 |
{ |
|
|
854 |
Bool corrupt; |
| 833 |
DState* s; |
855 |
DState* s; |
| 834 |
if (strm == NULL) return BZ_PARAM_ERROR; |
856 |
if (strm == NULL) return BZ_PARAM_ERROR; |
| 835 |
s = strm->state; |
857 |
s = strm->state; |
|
Lines 840-851
int BZ_API(BZ2_bzDecompress) ( bz_stream
Link Here
|
| 840 |
if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR; |
862 |
if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR; |
| 841 |
if (s->state == BZ_X_OUTPUT) { |
863 |
if (s->state == BZ_X_OUTPUT) { |
| 842 |
if (s->smallDecompress) |
864 |
if (s->smallDecompress) |
| 843 |
unRLE_obuf_to_output_SMALL ( s ); else |
865 |
corrupt = unRLE_obuf_to_output_SMALL ( s ); else |
| 844 |
unRLE_obuf_to_output_FAST ( s ); |
866 |
corrupt = unRLE_obuf_to_output_FAST ( s ); |
|
|
867 |
if (corrupt) return BZ_DATA_ERROR; |
| 845 |
if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) { |
868 |
if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) { |
| 846 |
BZ_FINALISE_CRC ( s->calculatedBlockCRC ); |
869 |
BZ_FINALISE_CRC ( s->calculatedBlockCRC ); |
| 847 |
if (s->verbosity >= 3) |
870 |
if (s->verbosity >= 3) |
| 848 |
VPrintf2 ( " {0x%x, 0x%x}", s->storedBlockCRC, |
871 |
VPrintf2 ( " {0x%08x, 0x%08x}", s->storedBlockCRC, |
| 849 |
s->calculatedBlockCRC ); |
872 |
s->calculatedBlockCRC ); |
| 850 |
if (s->verbosity >= 2) VPrintf0 ( "]" ); |
873 |
if (s->verbosity >= 2) VPrintf0 ( "]" ); |
| 851 |
if (s->calculatedBlockCRC != s->storedBlockCRC) |
874 |
if (s->calculatedBlockCRC != s->storedBlockCRC) |
|
Lines 863-869
int BZ_API(BZ2_bzDecompress) ( bz_stream
Link Here
|
| 863 |
Int32 r = BZ2_decompress ( s ); |
886 |
Int32 r = BZ2_decompress ( s ); |
| 864 |
if (r == BZ_STREAM_END) { |
887 |
if (r == BZ_STREAM_END) { |
| 865 |
if (s->verbosity >= 3) |
888 |
if (s->verbosity >= 3) |
| 866 |
VPrintf2 ( "\n combined CRCs: stored = 0x%x, computed = 0x%x", |
889 |
VPrintf2 ( "\n combined CRCs: stored = 0x%08x, computed = 0x%08x", |
| 867 |
s->storedCombinedCRC, s->calculatedCombinedCRC ); |
890 |
s->storedCombinedCRC, s->calculatedCombinedCRC ); |
| 868 |
if (s->calculatedCombinedCRC != s->storedCombinedCRC) |
891 |
if (s->calculatedCombinedCRC != s->storedCombinedCRC) |
| 869 |
return BZ_DATA_ERROR; |
892 |
return BZ_DATA_ERROR; |