5
5
/*-------------------------------------------------------------*/
8
This file is a part of bzip2 and/or libbzip2, a program and
9
library for lossless, block-sorting data compression.
11
Copyright (C) 1996-2000 Julian R Seward. All rights reserved.
13
Redistribution and use in source and binary forms, with or without
14
modification, are permitted provided that the following conditions
17
1. Redistributions of source code must retain the above copyright
18
notice, this list of conditions and the following disclaimer.
20
2. The origin of this software must not be misrepresented; you must
21
not claim that you wrote the original software. If you use this
22
software in a product, an acknowledgment in the product
23
documentation would be appreciated but is not required.
25
3. Altered source versions must be plainly marked as such, and must
26
not be misrepresented as being the original software.
28
4. The name of the author may not be used to endorse or promote
29
products derived from this software without specific prior written
32
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
33
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
36
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
38
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
40
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44
Julian Seward, Cambridge, UK.
46
bzip2/libbzip2 version 1.0 of 21 March 2000
48
This program is based on (at least) the work of:
58
For more information on these sources, see the manual.
64
0.9.0 -- original version.
7
/* ------------------------------------------------------------------
8
This file is part of bzip2/libbzip2, a program and library for
9
lossless, block-sorting data compression.
11
bzip2/libbzip2 version 1.0.5 of 10 December 2007
12
Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
14
Please read the WARNING, DISCLAIMER and PATENTS sections in the
17
This program is released under the terms of the license contained
19
------------------------------------------------------------------ */
22
0.9.0 -- original version.
66
23
0.9.0a/b -- no changes in this file.
69
* made zero-length BZ_FLUSH work correctly in bzCompress().
70
* fixed bzWrite/bzRead to ignore zero-length requests.
71
* fixed bzread to correctly handle read requests after EOF.
72
* wrong parameter order in call to bzDecompressInit in
73
bzBuffToBuffDecompress. Fixed.
24
0.9.0c -- made zero-length BZ_FLUSH work correctly in bzCompress().
25
fixed bzWrite/bzRead to ignore zero-length requests.
26
fixed bzread to correctly handle read requests after EOF.
27
wrong parameter order in call to bzDecompressInit in
28
bzBuffToBuffDecompress. Fixed.
76
31
#include "bzlib_private.h"
89
44
"\n\nbzip2/libbzip2: internal error number %d.\n"
90
45
"This is a bug in bzip2/libbzip2, %s.\n"
91
"Please report it to me at: jseward@acm.org. If this happened\n"
46
"Please report it to me at: jseward@bzip.org. If this happened\n"
92
47
"when you were using some program which uses libbzip2 as a\n"
93
48
"component, you should also report this bug to the author(s)\n"
94
49
"of that program. Please make an effort to report this bug;\n"
95
50
"timely and accurate bug reports eventually lead to higher\n"
96
"quality software. Thanks. Julian Seward, 21 March 2000.\n\n",
51
"quality software. Thanks. Julian Seward, 10 December 2007.\n\n",
56
if (errcode == 1007) {
58
"\n*** A special note about internal error number 1007 ***\n"
60
"Experience suggests that a common cause of i.e. 1007\n"
61
"is unreliable memory or other hardware. The 1007 assertion\n"
62
"just happens to cross-check the results of huge numbers of\n"
63
"memory reads/writes, and so acts (unintendedly) as a stress\n"
64
"test of your memory system.\n"
66
"I suggest the following: try compressing the file again,\n"
67
"possibly monitoring progress in detail with the -vv flag.\n"
69
"* If the error cannot be reproduced, and/or happens at different\n"
70
" points in compression, you may have a flaky memory system.\n"
71
" Try a memory-test program. I have used Memtest86\n"
72
" (www.memtest86.com). At the time of writing it is free (GPLd).\n"
73
" Memtest86 tests memory much more thorougly than your BIOSs\n"
74
" power-on test, and may find failures that the BIOS doesn't.\n"
76
"* If the error can be repeatably reproduced, this is a bug in\n"
77
" bzip2, and I would very much like to hear about it. Please\n"
78
" let me know, and, ideally, save a copy of the file causing the\n"
79
" problem -- without which I will be unable to investigate it.\n"
811
818
if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR;
812
819
if (s->state == BZ_X_OUTPUT) {
813
820
if (s->smallDecompress)
814
unRLE_obuf_to_output_SMALL ( s ); else
815
unRLE_obuf_to_output_FAST ( s );
821
corrupt = unRLE_obuf_to_output_SMALL ( s ); else
822
corrupt = unRLE_obuf_to_output_FAST ( s );
823
if (corrupt) return BZ_DATA_ERROR;
816
824
if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) {
817
825
BZ_FINALISE_CRC ( s->calculatedBlockCRC );
818
826
if (s->verbosity >= 3)
819
VPrintf2 ( " {0x%x, 0x%x}", s->storedBlockCRC,
827
VPrintf2 ( " {0x%08x, 0x%08x}", s->storedBlockCRC,
820
828
s->calculatedBlockCRC );
821
829
if (s->verbosity >= 2) VPrintf0 ( "]" );
822
830
if (s->calculatedBlockCRC != s->storedBlockCRC)