From c3a3886e9ccb17c603b8e72a76aff5b25903838b Mon Sep 17 00:00:00 2001 From: Brigham Keys Date: Wed, 13 Sep 2017 19:16:12 -0500 Subject: [PATCH 1/3] Updated version of bzip2 --- .gitignore | 1 + .vscode/.cmaketools.json | 5 + CHANGES | 12 +- Makefile | 6 +- Makefile-libbz2_so | 14 +- README | 9 +- README.COMPILATION.PROBLEMS | 6 +- README.XML.STUFF | 4 +- blocksort.c | 4 +- bzip2.1 | 6 +- bzip2.1.preformatted | 6 +- bzip2.c | 8 +- bzip2.txt | 6 +- bzip2recover.c | 6 +- bzlib.c | 4 +- bzlib.h | 4 +- bzlib_private.h | 6 +- compress.c | 4 +- crctable.c | 4 +- decompress.c | 24 ++- entities.xml | 6 +- format.pl | 4 +- huffman.c | 4 +- manual.html | 344 ++++++++++++++++++------------------ manual.pdf | Bin 288137 -> 256905 bytes manual.ps | Bin 1355344 -> 1143101 bytes manual.xml | 40 ++--- mk251.c | 4 +- randtable.c | 4 +- spewG.c | 4 +- unzcrash.c | 4 +- xmlproc.sh | 4 +- 32 files changed, 298 insertions(+), 259 deletions(-) create mode 100644 .vscode/.cmaketools.json diff --git a/.gitignore b/.gitignore index 5d32d3b..4a8d1ed 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ bzcmp.1 bzegrep.1 bzfgrep.1 bzless.1 +build/ \ No newline at end of file diff --git a/.vscode/.cmaketools.json b/.vscode/.cmaketools.json new file mode 100644 index 0000000..e8a5846 --- /dev/null +++ b/.vscode/.cmaketools.json @@ -0,0 +1,5 @@ +{ + "variant": null, + "activeEnvironments": [], + "codeModel": null +} \ No newline at end of file diff --git a/CHANGES b/CHANGES index 6e4f65e..81e97ca 100644 --- a/CHANGES +++ b/CHANGES @@ -2,8 +2,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. @@ -317,3 +317,11 @@ Fixes some minor bugs since the last version, 1.0.3. ~~~~~~~~~~~~~~~~~ Security fix only. Fixes CERT-FI 20469 as it applies to bzip2. + +1.0.6 (6 Sept 10) +~~~~~~~~~~~~~~~~~ + +* Security fix for CVE-2010-0405. This was reported by Mikolaj + Izdebski. + +* Make the documentation build on Ubuntu 10.04 diff --git a/Makefile b/Makefile index eb09753..9754ddf 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,8 @@ # This file is part of bzip2/libbzip2, a program and library for # lossless, block-sorting data compression. # -# bzip2/libbzip2 version 1.0.5 of 10 December 2007 -# Copyright (C) 1996-2007 Julian Seward +# bzip2/libbzip2 version 1.0.6 of 6 September 2010 +# Copyright (C) 1996-2010 Julian Seward # # Please read the WARNING, DISCLAIMER and PATENTS sections in the # README file. @@ -137,7 +137,7 @@ bzip2recover.o: bzip2recover.c distclean: clean rm -f manual.ps manual.html manual.pdf -DISTNAME=bzip2-1.0.5 +DISTNAME=bzip2-1.0.6 dist: check manual rm -f $(DISTNAME) ln -s -f . $(DISTNAME) diff --git a/Makefile-libbz2_so b/Makefile-libbz2_so index 9a13c77..e58791b 100644 --- a/Makefile-libbz2_so +++ b/Makefile-libbz2_so @@ -1,6 +1,6 @@ # This Makefile builds a shared version of the library, -# libbz2.so.1.0.4, with soname libbz2.so.1.0, +# libbz2.so.1.0.6, with soname libbz2.so.1.0, # at least on x86-Linux (RedHat 7.2), # with gcc-2.96 20000731 (Red Hat Linux 7.1 2.96-98). # Please see the README file for some important info @@ -10,8 +10,8 @@ # This file is part of bzip2/libbzip2, a program and library for # lossless, block-sorting data compression. # -# bzip2/libbzip2 version 1.0.5 of 10 December 2007 -# Copyright (C) 1996-2007 Julian Seward +# bzip2/libbzip2 version 1.0.6 of 6 September 2010 +# Copyright (C) 1996-2010 Julian Seward # # Please read the WARNING, DISCLAIMER and PATENTS sections in the # README file. @@ -35,13 +35,13 @@ OBJS= blocksort.o \ bzlib.o all: $(OBJS) - $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.4 $(OBJS) - $(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.4 + $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.6 $(OBJS) + $(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.6 rm -f libbz2.so.1.0 - ln -s libbz2.so.1.0.4 libbz2.so.1.0 + ln -s libbz2.so.1.0.6 libbz2.so.1.0 clean: - rm -f $(OBJS) bzip2.o libbz2.so.1.0.4 libbz2.so.1.0 bzip2-shared + rm -f $(OBJS) bzip2.o libbz2.so.1.0.6 libbz2.so.1.0 bzip2-shared blocksort.o: blocksort.c $(CC) $(CFLAGS) -c blocksort.c diff --git a/README b/README index e17a84e..9fb0f63 100644 --- a/README +++ b/README @@ -6,8 +6,8 @@ This version is fully compatible with the previous public releases. This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. -bzip2/libbzip2 version 1.0.5 of 10 December 2007 -Copyright (C) 1996-2007 Julian Seward +bzip2/libbzip2 version 1.0.6 of 6 September 2010 +Copyright (C) 1996-2010 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in this file. @@ -181,6 +181,10 @@ WHAT'S NEW IN 1.0.5 ? See the CHANGES file. +WHAT'S NEW IN 1.0.6 ? + + See the CHANGES file. + I hope you find bzip2 useful. Feel free to contact me at jseward@bzip.org @@ -208,3 +212,4 @@ Cambridge, UK. 15 February 2005 (bzip2, version 1.0.3) 20 December 2006 (bzip2, version 1.0.4) 10 December 2007 (bzip2, version 1.0.5) + 6 Sept 2010 (bzip2, version 1.0.6) diff --git a/README.COMPILATION.PROBLEMS b/README.COMPILATION.PROBLEMS index 22b95c6..667d0d6 100644 --- a/README.COMPILATION.PROBLEMS +++ b/README.COMPILATION.PROBLEMS @@ -2,8 +2,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. -bzip2/libbzip2 version 1.0.5 of 10 December 2007 -Copyright (C) 1996-2007 Julian Seward +bzip2/libbzip2 version 1.0.6 of 6 September 2010 +Copyright (C) 1996-2010 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. @@ -12,7 +12,7 @@ This program is released under the terms of the license contained in the file LICENSE. ------------------------------------------------------------------ -bzip2-1.0.5 should compile without problems on the vast majority of +bzip2-1.0.6 should compile without problems on the vast majority of platforms. Using the supplied Makefile, I've built and tested it myself for x86-linux and amd64-linux. With makefile.msc, Visual C++ 6.0 and nmake, you can build a native Win32 version too. Large file diff --git a/README.XML.STUFF b/README.XML.STUFF index 1a5b4c5..3a57f3f 100644 --- a/README.XML.STUFF +++ b/README.XML.STUFF @@ -2,8 +2,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/blocksort.c b/blocksort.c index bd2dec1..d0d662c 100644 --- a/blocksort.c +++ b/blocksort.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/bzip2.1 b/bzip2.1 index a313f2d..ce3a78e 100644 --- a/bzip2.1 +++ b/bzip2.1 @@ -1,7 +1,7 @@ .PU .TH bzip2 1 .SH NAME -bzip2, bunzip2 \- a block-sorting file compressor, v1.0.4 +bzip2, bunzip2 \- a block-sorting file compressor, v1.0.6 .br bzcat \- decompresses files to stdout .br @@ -405,11 +405,11 @@ I/O error messages are not as helpful as they could be. tries hard to detect I/O errors and exit cleanly, but the details of what the problem is sometimes seem rather misleading. -This manual page pertains to version 1.0.4 of +This manual page pertains to version 1.0.6 of .I bzip2. Compressed data created by this version is entirely forwards and backwards compatible with the previous public releases, versions -0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1, 1.0.2 and 1.0.3, but with the following +0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1, 1.0.2 and above, but with the following exception: 0.9.0 and above can correctly decompress multiple concatenated compressed files. 0.1pl2 cannot do this; it will stop after decompressing just the first file in the stream. diff --git a/bzip2.1.preformatted b/bzip2.1.preformatted index 15e16e5..63c33be 100644 --- a/bzip2.1.preformatted +++ b/bzip2.1.preformatted @@ -3,7 +3,7 @@ bzip2(1) bzip2(1) NNAAMMEE - bzip2, bunzip2 − a block‐sorting file compressor, v1.0.4 + bzip2, bunzip2 − a block‐sorting file compressor, v1.0.6 bzcat − decompresses files to stdout bzip2recover − recovers data from damaged bzip2 files @@ -348,11 +348,11 @@ CCAAVVEEAATTSS but the details of what the problem is sometimes seem rather misleading. - This manual page pertains to version 1.0.4 of _b_z_i_p_2_. Com­ + This manual page pertains to version 1.0.6 of _b_z_i_p_2_. Com­ pressed data created by this version is entirely forwards and backwards compatible with the previous public releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1, - 1.0.2 and 1.0.3, but with the following exception: 0.9.0 + 1.0.2 and above, but with the following exception: 0.9.0 and above can correctly decompress multiple concatenated compressed files. 0.1pl2 cannot do this; it will stop after decompressing just the first file in the stream. diff --git a/bzip2.c b/bzip2.c index 3904107..6de9d1d 100644 --- a/bzip2.c +++ b/bzip2.c @@ -7,8 +7,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. @@ -1605,11 +1605,11 @@ void license ( void ) "bzip2, a block-sorting file compressor. " "Version %s.\n" " \n" - " Copyright (C) 1996-2007 by Julian Seward.\n" + " Copyright (C) 1996-2010 by Julian Seward.\n" " \n" " This program is free software; you can redistribute it and/or modify\n" " it under the terms set out in the LICENSE file, which is included\n" - " in the bzip2-1.0.5 source distribution.\n" + " in the bzip2-1.0.6 source distribution.\n" " \n" " This program is distributed in the hope that it will be useful,\n" " but WITHOUT ANY WARRANTY; without even the implied warranty of\n" diff --git a/bzip2.txt b/bzip2.txt index 4fb9c74..d2deb39 100644 --- a/bzip2.txt +++ b/bzip2.txt @@ -1,6 +1,6 @@ NAME - bzip2, bunzip2 - a block-sorting file compressor, v1.0.4 + bzip2, bunzip2 - a block-sorting file compressor, v1.0.6 bzcat - decompresses files to stdout bzip2recover - recovers data from damaged bzip2 files @@ -345,11 +345,11 @@ CAVEATS but the details of what the problem is sometimes seem rather misleading. - This manual page pertains to version 1.0.4 of bzip2. Com- + This manual page pertains to version 1.0.6 of bzip2. Com- pressed data created by this version is entirely forwards and backwards compatible with the previous public releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1, - 1.0.2 and 1.0.3, but with the following exception: 0.9.0 + 1.0.2 and above, but with the following exception: 0.9.0 and above can correctly decompress multiple concatenated compressed files. 0.1pl2 cannot do this; it will stop after decompressing just the first file in the stream. diff --git a/bzip2recover.c b/bzip2recover.c index 5f6d621..f9de049 100644 --- a/bzip2recover.c +++ b/bzip2recover.c @@ -7,8 +7,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. @@ -313,7 +313,7 @@ Int32 main ( Int32 argc, Char** argv ) inFileName[0] = outFileName[0] = 0; fprintf ( stderr, - "bzip2recover 1.0.5: extracts blocks from damaged .bz2 files.\n" ); + "bzip2recover 1.0.6: extracts blocks from damaged .bz2 files.\n" ); if (argc != 2) { fprintf ( stderr, "%s: usage is `%s damaged_file_name'.\n", diff --git a/bzlib.c b/bzlib.c index ef86c91..bd358a7 100644 --- a/bzlib.c +++ b/bzlib.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/bzlib.h b/bzlib.h index c5b75d6..8277123 100644 --- a/bzlib.h +++ b/bzlib.h @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/bzlib_private.h b/bzlib_private.h index 2342787..5d0217f 100644 --- a/bzlib_private.h +++ b/bzlib_private.h @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. @@ -36,7 +36,7 @@ /*-- General stuff. --*/ -#define BZ_VERSION "1.0.5, 10-Dec-2007" +#define BZ_VERSION "1.0.6, 6-Sept-2010" typedef char Char; typedef unsigned char Bool; diff --git a/compress.c b/compress.c index 8c80a07..caf7696 100644 --- a/compress.c +++ b/compress.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/crctable.c b/crctable.c index 215687b..1fea7e9 100644 --- a/crctable.c +++ b/crctable.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/decompress.c b/decompress.c index bba5e0f..311f566 100644 --- a/decompress.c +++ b/decompress.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. @@ -381,6 +381,13 @@ Int32 BZ2_decompress ( DState* s ) es = -1; N = 1; do { + /* Check that N doesn't get too big, so that es doesn't + go negative. The maximum value that can be + RUNA/RUNB encoded is equal to the block size (post + the initial RLE), viz, 900k, so bounding N at 2 + million should guard against overflow without + rejecting any legitimate inputs. */ + if (N >= 2*1024*1024) RETURN(BZ_DATA_ERROR); if (nextSym == BZ_RUNA) es = es + (0+1) * N; else if (nextSym == BZ_RUNB) es = es + (1+1) * N; N = N * 2; @@ -485,15 +492,28 @@ Int32 BZ2_decompress ( DState* s ) RETURN(BZ_DATA_ERROR); /*-- Set up cftab to facilitate generation of T^(-1) --*/ + /* Check: unzftab entries in range. */ + for (i = 0; i <= 255; i++) { + if (s->unzftab[i] < 0 || s->unzftab[i] > nblock) + RETURN(BZ_DATA_ERROR); + } + /* Actually generate cftab. */ s->cftab[0] = 0; for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1]; for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1]; + /* Check: cftab entries in range. */ for (i = 0; i <= 256; i++) { if (s->cftab[i] < 0 || s->cftab[i] > nblock) { /* s->cftab[i] can legitimately be == nblock */ RETURN(BZ_DATA_ERROR); } } + /* Check: cftab entries non-descending. */ + for (i = 1; i <= 256; i++) { + if (s->cftab[i-1] > s->cftab[i]) { + RETURN(BZ_DATA_ERROR); + } + } s->state_out_len = 0; s->state_out_ch = 0; diff --git a/entities.xml b/entities.xml index e9e0553..4b28f34 100644 --- a/entities.xml +++ b/entities.xml @@ -1,9 +1,9 @@ - + - - + + diff --git a/format.pl b/format.pl index 1928d15..f169fd9 100755 --- a/format.pl +++ b/format.pl @@ -4,8 +4,8 @@ # This file is part of bzip2/libbzip2, a program and library for # lossless, block-sorting data compression. # -# bzip2/libbzip2 version 1.0.5 of 10 December 2007 -# Copyright (C) 1996-2007 Julian Seward +# bzip2/libbzip2 version 1.0.6 of 6 September 2010 +# Copyright (C) 1996-2010 Julian Seward # # Please read the WARNING, DISCLAIMER and PATENTS sections in the # README file. diff --git a/huffman.c b/huffman.c index 87e79e3..2283fdb 100644 --- a/huffman.c +++ b/huffman.c @@ -8,8 +8,8 @@ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward + bzip2/libbzip2 version 1.0.6 of 6 September 2010 + Copyright (C) 1996-2010 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. diff --git a/manual.html b/manual.html index bd9eac8..f59427f 100644 --- a/manual.html +++ b/manual.html @@ -1,8 +1,8 @@ -bzip2 and libbzip2, version 1.0.5 - +bzip2 and libbzip2, version 1.0.6 + -
+

-bzip2 and libbzip2, version 1.0.5

+bzip2 and libbzip2, version 1.0.6

A program and library for data compression

@@ -91,29 +91,29 @@

http://www.bzip.org
-

Version 1.0.5 of 10 December 2007

-
-
-

This program, bzip2, the +

Version 1.0.6 of 6 September 2010

+
+
+

This program, bzip2, the associated library libbzip2, and - all documentation, are copyright 1996-2007 Julian Seward. + all documentation, are copyright 1996-2010 Julian Seward. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

-
-
+

1.Introduction

bzip2 compresses files @@ -228,19 +228,19 @@

library interface. Most of the manual is devoted to this library, not the program, which is good news if your interest is only in the program.

-
-
+

2.How to use bzip2

@@ -260,34 +260,34 @@

This chapter contains a copy of the bzip2 man page, and nothing else.

-
+

2.1.NAME

-
    -
  • bzip2, +

      +
    • bzip2, bunzip2 - a block-sorting file - compressor, v1.0.4

    • -
    • bzcat - + compressor, v1.0.6

    • +
    • bzcat - decompresses files to stdout

    • -
    • bzip2recover - +

    • bzip2recover - recovers data from damaged bzip2 files

-
+

2.2.SYNOPSIS

-
    -
  • bzip2 [ +

      +
    • bzip2 [ -cdfkqstvzVL123456789 ] [ filenames ... ]

    • -
    • bunzip2 [ +

    • bunzip2 [ -fkvsVL ] [ filenames ... ]

    • -
    • bzcat [ -s ] [ +

    • bzcat [ -s ] [ filenames ... ]

    • -
    • bzip2recover +

    • bzip2recover filename

-
+

2.3.DESCRIPTION

bzip2 compresses files @@ -329,20 +329,20 @@

bzip2 attempts to guess the filename for the decompressed file from that of the compressed file as follows:

-
    -
  • filename.bz2 +

      +
    • filename.bz2 becomes filename

    • -
    • filename.bz +

    • filename.bz becomes filename

    • -
    • filename.tbz2 +

    • filename.tbz2 becomes filename.tar

    • -
    • filename.tbz +

    • filename.tbz becomes filename.tar

    • -
    • anyothername +

    • anyothername becomes anyothername.out

    @@ -407,7 +407,7 @@

    consistency error (eg, bug) which caused bzip2 to panic.

-
+

2.4.OPTIONS

@@ -458,7 +458,7 @@

the same figure, at the expense of your compression ratio. In short, if your machine is low on memory (8 megabytes or less), use -s for everything. See - MEMORY MANAGEMENT below.

+ MEMORY MANAGEMENT below.

-q --quiet

Suppress non-essential warning messages. @@ -478,7 +478,7 @@

-9 (or -best)

Set the block size to 100 k, 200 k ... 900 k - when compressing. Has no effect when decompressing. See MEMORY MANAGEMENT below. The + when compressing. Has no effect when decompressing. See MEMORY MANAGEMENT below. The --fast and --best aliases are primarily for GNU gzip compatibility. @@ -502,7 +502,7 @@

renders these flags irrelevant.

-
+

2.5.MEMORY MANAGEMENT

bzip2 compresses large @@ -574,7 +574,7 @@

-8 6800k 3300k 2100k 828642 -9 7600k 3700k 2350k 828642

-
+

2.6.RECOVERING DATA FROM DAMAGED FILES

bzip2 compresses files in @@ -612,7 +612,7 @@

loss through media or transmission errors, you might consider compressing with a smaller block size.

-
+

2.7.PERFORMANCE NOTES

The sorting phase of compression gathers together similar @@ -638,14 +638,14 @@

bzip2 will perform best on machines with very large caches.

-
+

2.8.CAVEATS

I/O error messages are not as helpful as they could be. bzip2 tries hard to detect I/O errors and exit cleanly, but the details of what the problem is sometimes seem rather misleading.

-

This manual page pertains to version 1.0.5 of +

This manual page pertains to version 1.0.6 of bzip2. Compressed data created by this version is entirely forwards and backwards compatible with the previous public releases, versions 0.1pl2, 0.9.0 and 0.9.5, 1.0.0, @@ -665,7 +665,7 @@

MaybeUInt64 set to be an unsigned 64-bit integer.

-
+

2.9.AUTHOR

Julian Seward, @@ -690,7 +690,7 @@

advice and were generally helpful.

-
+

3. Programming with libbzip2 @@ -707,34 +707,34 @@

3.2. Error handling
3.3. Low-level interface
-
3.3.1. BZ2_bzCompressInit
-
3.3.2. BZ2_bzCompress
-
3.3.3. BZ2_bzCompressEnd
-
3.3.4. BZ2_bzDecompressInit
-
3.3.5. BZ2_bzDecompress
-
3.3.6. BZ2_bzDecompressEnd
+
3.3.1. BZ2_bzCompressInit
+
3.3.2. BZ2_bzCompress
+
3.3.3. BZ2_bzCompressEnd
+
3.3.4. BZ2_bzDecompressInit
+
3.3.5. BZ2_bzDecompress
+
3.3.6. BZ2_bzDecompressEnd
3.4. High-level interface
-
3.4.1. BZ2_bzReadOpen
-
3.4.2. BZ2_bzRead
-
3.4.3. BZ2_bzReadGetUnused
-
3.4.4. BZ2_bzReadClose
-
3.4.5. BZ2_bzWriteOpen
-
3.4.6. BZ2_bzWrite
-
3.4.7. BZ2_bzWriteClose
+
3.4.1. BZ2_bzReadOpen
+
3.4.2. BZ2_bzRead
+
3.4.3. BZ2_bzReadGetUnused
+
3.4.4. BZ2_bzReadClose
+
3.4.5. BZ2_bzWriteOpen
+
3.4.6. BZ2_bzWrite
+
3.4.7. BZ2_bzWriteClose
3.4.8. Handling embedded compressed data streams
3.4.9. Standard file-reading/writing code
3.5. Utility functions
-
3.5.1. BZ2_bzBuffToBuffCompress
-
3.5.2. BZ2_bzBuffToBuffDecompress
+
3.5.1. BZ2_bzBuffToBuffCompress
+
3.5.2. BZ2_bzBuffToBuffDecompress
-
3.6. zlib compatibility functions
-
3.7. Using the library in a stdio-free environment
+
3.6. zlib compatibility functions
+
3.7. Using the library in a stdio-free environment
-
3.7.1. Getting rid of stdio
+
3.7.1. Getting rid of stdio
3.7.2. Critical error handling
3.8. Making a Windows DLL
@@ -744,8 +744,8 @@

libbzip2.

For general background information, particularly about memory use and performance aspects, you'd be well advised to read -How to use bzip2 as well.

-
+How to use bzip2 as well.

+

3.1.Top-level structure

libbzip2 is a flexible @@ -765,7 +765,7 @@

To use any part of the library, you need to #include <bzlib.h> into your sources.

-
+

3.1.1.Low-level summary

This interface provides services for compressing and @@ -800,7 +800,7 @@

consumer-pull style of activity, or producer-push, or a mixture of both.

-
+

3.1.2.High-level summary

This interface provides some handy wrappers around the @@ -839,7 +839,7 @@

file operations and file attributes, whilst not being much of an imposition on the programmer.

-
+

3.1.3.Utility functions summary

For very simple needs, @@ -871,7 +871,7 @@

library to be built as a Windows DLL.

-
+

3.2.Error handling

The library is designed to recover cleanly in all @@ -1008,12 +1008,12 @@

buffer provided.

-
+

3.3.Low-level interface

-
+

-3.3.1.BZ2_bzCompressInit

+3.3.1.BZ2_bzCompressInit

typedef struct {
   char *next_in;
   unsigned int avail_in;
@@ -1137,9 +1137,9 @@ 

if BZ_OK is returned no specific action needed in case of error

-
+

-3.3.2.BZ2_bzCompress

+3.3.2.BZ2_bzCompress

int BZ2_bzCompress ( bz_stream *strm, int action );

Provides more input and/or output buffer space for the library. The caller maintains input and output buffers, and @@ -1296,20 +1296,20 @@

Return value = BZ_SEQUENCE_ERROR

That still looks complicated? Well, fair enough. The usual sequence of calls for compressing a load of data is:

-
    -
  1. Get started with +

      +
    1. Get started with BZ2_bzCompressInit.

    2. -
    3. Shovel data in and shlurp out its compressed form +

    4. Shovel data in and shlurp out its compressed form using zero or more calls of BZ2_bzCompress with action = BZ_RUN.

    5. -
    6. Finish up. Repeatedly call +

    7. Finish up. Repeatedly call BZ2_bzCompress with action = BZ_FINISH, copying out the compressed output, until BZ_STREAM_END is returned.

    8. -
    9. Close up and go home. Call +

    10. Close up and go home. Call BZ2_bzCompressEnd.

    If the data you want to compress fits into your input @@ -1329,9 +1329,9 @@

    BZ_PARAM_ERROR
       if strm is NULL, or strm->s is NULL

-
+

-3.3.3.BZ2_bzCompressEnd

+3.3.3.BZ2_bzCompressEnd

int BZ2_bzCompressEnd ( bz_stream *strm );

Releases all memory associated with a compression stream.

@@ -1339,9 +1339,9 @@

BZ_PARAM_ERROR  if strm is NULL or strm->s is NULL
 BZ_OK           otherwise

-
+

-3.3.4.BZ2_bzDecompressInit

+3.3.4.BZ2_bzDecompressInit

int BZ2_bzDecompressInit ( bz_stream *strm, int verbosity, int small );

Prepares for decompression. As with BZ2_bzCompressInit, a @@ -1364,7 +1364,7 @@

library will use an alternative decompression algorithm which uses less memory but at the cost of decompressing more slowly (roughly speaking, half the speed, but the maximum memory -requirement drops to around 2300k). See How to use bzip2 +requirement drops to around 2300k). See How to use bzip2 for more information on memory management.

Note that the amount of memory needed to decompress a stream cannot be determined until the stream's header has been @@ -1386,9 +1386,9 @@

if BZ_OK was returned no specific action required in case of error

-
+

-3.3.5.BZ2_bzDecompress

+3.3.5.BZ2_bzDecompress
int BZ2_bzDecompress ( bz_stream *strm );

Provides more input and/out output buffer space for the library. The caller maintains input and output buffers, and uses @@ -1461,9 +1461,9 @@

BZ2_bzDecompressEnd otherwise

-
+

-3.3.6.BZ2_bzDecompressEnd

+3.3.6.BZ2_bzDecompressEnd
int BZ2_bzDecompressEnd ( bz_stream *strm );

Releases all memory associated with a decompression stream.

@@ -1476,14 +1476,14 @@

  None.

-
+

3.4.High-level interface

This interface provides functions for reading and writing bzip2 format files. First, some general points.

-
    -
  • All of the functions take an +

      +
    • All of the functions take an int* first argument, bzerror. After each call, bzerror should be consulted @@ -1500,7 +1500,7 @@

      of the difficulty. bzerror may also be set to various other values; precise details are given on a per-function basis below.

    • -
    • If bzerror indicates +

    • If bzerror indicates an error (ie, anything except BZ_OK and BZ_STREAM_END), you should @@ -1519,22 +1519,22 @@

      BZ2_bzReadClose (BZ2_bzWriteClose) should then be called to clean up.

    • -
    • The FILE* arguments +

    • The FILE* arguments passed to BZ2_bzReadOpen / BZ2_bzWriteOpen should be set to binary mode. Most Unix systems will do this by default, but other platforms, including Windows and Mac, will not. If you omit this, you may encounter problems when moving code to new platforms.

    • -
    • Memory allocation requests are handled by +

    • Memory allocation requests are handled by malloc / free. At present there is no facility for user-defined memory allocators in the file I/O functions (could easily be added, though).

    -
    +

    -3.4.1.BZ2_bzReadOpen

    +3.4.1.BZ2_bzReadOpen
typedef void BZFILE;
 
 BZFILE *BZ2_bzReadOpen( int *bzerror, FILE *f, 
@@ -1594,9 +1594,9 @@ 

BZ2_bzClose otherwise

-
+

-3.4.2.BZ2_bzRead

+3.4.2.BZ2_bzRead
int BZ2_bzRead ( int *bzerror, BZFILE *b, void *buf, int len );

Reads up to len (uncompressed) bytes from the compressed file @@ -1668,9 +1668,9 @@

BZ2_bzReadClose otherwise -
+

-3.4.3.BZ2_bzReadGetUnused

+3.4.3.BZ2_bzReadGetUnused

void BZ2_bzReadGetUnused( int* bzerror, BZFILE *b, 
                           void** unused, int* nUnused );

Returns data which was read from the compressed file but @@ -1697,9 +1697,9 @@

Allowable next actions:

BZ2_bzReadClose
-
+

-3.4.4.BZ2_bzReadClose

+3.4.4.BZ2_bzReadClose

void BZ2_bzReadClose ( int *bzerror, BZFILE *b );

Releases all memory pertaining to the compressed file b. @@ -1717,9 +1717,9 @@

Allowable next actions:

none
-
+

-3.4.5.BZ2_bzWriteOpen

+3.4.5.BZ2_bzWriteOpen

BZFILE *BZ2_bzWriteOpen( int *bzerror, FILE *f, 
                          int blockSize100k, int verbosity,
                          int workFactor );
@@ -1763,9 +1763,9 @@

BZ2_bzWriteClose otherwise -
+

-3.4.6.BZ2_bzWrite

+3.4.6.BZ2_bzWrite

void BZ2_bzWrite ( int *bzerror, BZFILE *b, void *buf, int len );

Absorbs len bytes from the buffer buf, eventually to be @@ -1781,9 +1781,9 @@

BZ_OK otherwise -
+

-3.4.7.BZ2_bzWriteClose

+3.4.7.BZ2_bzWriteClose

void BZ2_bzWriteClose( int *bzerror, BZFILE* f,
                        int abandon,
                        unsigned int* nbytes_in,
@@ -1833,20 +1833,20 @@ 

BZ_OK otherwise

-
+

3.4.8.Handling embedded compressed data streams

The high-level library facilitates use of bzip2 data streams which form some part of a surrounding, larger data stream.

-
    -
  • For writing, the library takes an open file handle, +

      +
    • For writing, the library takes an open file handle, writes compressed data to it, fflushes it but does not fclose it. The calling application can write its own data before and after the compressed data stream, using that same file handle.

    • -
    • Reading is more complex, and the facilities are not as +

    • Reading is more complex, and the facilities are not as general as they could be since generality is hard to reconcile with efficiency. BZ2_bzRead reads from the compressed file in blocks of size @@ -1882,7 +1882,7 @@

      bite the bullet and get to grips with the low-level interface.

    -
    +

    3.4.9.Standard file-reading/writing code

    Here's how you'd write data to a compressed file:

    @@ -1949,12 +1949,12 @@

    }

    -
    +

    3.5.Utility functions

    -
    +

    -3.5.1.BZ2_bzBuffToBuffCompress

    +3.5.1.BZ2_bzBuffToBuffCompress
    int BZ2_bzBuffToBuffCompress( char*         dest,
                                   unsigned int* destLen,
                                   char*         source,
    @@ -2005,9 +2005,9 @@ 

    BZ_OK otherwise

    -
    +

    -3.5.2.BZ2_bzBuffToBuffDecompress

    +3.5.2.BZ2_bzBuffToBuffDecompress
int BZ2_bzBuffToBuffDecompress( char*         dest,
                                 unsigned int* destLen,
                                 char*         source,
@@ -2065,9 +2065,9 @@ 

otherwise

-
+

-3.6.zlib compatibility functions

+3.6.zlib compatibility functions

Yoshioka Tsuneo has contributed some functions to give better zlib compatibility. These functions are BZ2_bzopen, @@ -2108,12 +2108,12 @@

*errnum to its numerical value.

-
+

-3.7.Using the library in a stdio-free environment

-
+3.7.Using the library in a stdio-free environment

+

-3.7.1.Getting rid of stdio

+3.7.1.Getting rid of stdio

In a deeply embedded application, you might want to use just the memory-to-memory functions. You can do this conveniently by compiling the library with preprocessor symbol @@ -2131,7 +2131,7 @@

When compiled like this, all functions will ignore verbosity settings.

-
+

3.7.2.Critical error handling

libbzip2 contains a number @@ -2143,13 +2143,13 @@

message:

bzip2/libbzip2: internal error number N.

-

This is a bug in bzip2/libbzip2, 1.0.5 of 10 December 2007. +

This is a bug in bzip2/libbzip2, 1.0.6 of 6 September 2010. Please report it to me at: jseward@bzip.org. If this happened when you were using some program which uses libbzip2 as a component, you should also report this bug to the author(s) of that program. Please make an effort to report this bug; timely and accurate bug reports eventually lead to higher -quality software. Thanks. Julian Seward, 10 December 2007. +quality software. Thanks. Julian Seward, 6 September 2010.

where N is some error code @@ -2176,7 +2176,7 @@

recovered from.

-
+

3.8.Making a Windows DLL

Everything related to Windows has been contributed by @@ -2218,7 +2218,7 @@

plausible.

-
+

4.Miscellanea

@@ -2233,7 +2233,7 @@

These are just some random thoughts of mine. Your mileage may vary.

-
+

4.1.Limitations of the compressed file format

bzip2-1.0.X, @@ -2250,15 +2250,15 @@

shown complexities in the file format which slow down decompression and, in retrospect, are unnecessary. These are:

-