diff --git a/contrib/bzip2/CHANGES b/contrib/bzip2/CHANGES index d98439543669..e31b03a0118b 100644 --- a/contrib/bzip2/CHANGES +++ b/contrib/bzip2/CHANGES @@ -251,3 +251,25 @@ of bzip2: * added --fast and --best aliases for -1 -9 for gzip compatibility. + +1.0.3 (15 Feb 05) +~~~~~~~~~~~~~~~~~ +Fixes some minor bugs since the last version, 1.0.2. + +* Further robustification against corrupted compressed data. + There are currently no known bitstreams which can cause the + decompressor to crash, loop or access memory which does not + belong to it. If you are using bzip2 or the library to + decompress bitstreams from untrusted sources, an upgrade + to 1.0.3 is recommended. + +* The documentation has been converted to XML, from which html + and pdf can be derived. + +* Various minor bugs in the documentation have been fixed. + +* Fixes for various compilation warnings with newer versions of + gcc, and on 64-bit platforms. + +* The BZ_NO_STDIO cpp symbol was not properly observed in 1.0.2. + This has been fixed. diff --git a/contrib/bzip2/LICENSE b/contrib/bzip2/LICENSE index 9d4fa4379089..e60845b4dcc3 100644 --- a/contrib/bzip2/LICENSE +++ b/contrib/bzip2/LICENSE @@ -1,6 +1,7 @@ -This program, "bzip2" and associated library "libbzip2", are -copyright (C) 1996-2002 Julian R Seward. All rights reserved. +This program, "bzip2", the associated library "libbzip2", and all +documentation, are copyright (C) 1996-2005 Julian R Seward. All +rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -35,5 +36,5 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. jseward@acm.org -bzip2/libbzip2 version 1.0.2 of 30 December 2001 +bzip2/libbzip2 version 1.0.3 of 15 February 2005 diff --git a/contrib/bzip2/Makefile b/contrib/bzip2/Makefile index 8305235fe24c..eea329a626e1 100644 --- a/contrib/bzip2/Makefile +++ b/contrib/bzip2/Makefile @@ -7,9 +7,8 @@ AR=ar RANLIB=ranlib LDFLAGS= -# Suitably paranoid flags to avoid bugs in gcc-2.7 BIGFILES=-D_FILE_OFFSET_BITS=64 -CFLAGS=-Wall -Winline -O2 -fomit-frame-pointer -fno-strength-reduce $(BIGFILES) +CFLAGS=-Wall -Winline -O -g $(BIGFILES) # Where you want it installed when you do 'make install' PREFIX=/usr @@ -96,7 +95,6 @@ install: bzip2 bzip2recover echo ".so man1/bzmore.1" > $(PREFIX)/man/man1/bzless.1 echo ".so man1/bzdiff.1" > $(PREFIX)/man/man1/bzcmp.1 -distclean: clean clean: rm -f *.o libbz2.a bzip2 bzip2recover \ sample1.rb2 sample2.rb2 sample3.rb2 \ @@ -122,8 +120,12 @@ bzip2.o: bzip2.c bzip2recover.o: bzip2recover.c $(CC) $(CFLAGS) -c bzip2recover.c -DISTNAME=bzip2-1.0.2 -tarfile: + +distclean: clean + rm -f manual.ps manual.html manual.pdf + +DISTNAME=bzip2-1.0.3 +dist: check manual rm -f $(DISTNAME) ln -sf . $(DISTNAME) tar cvf $(DISTNAME).tar \ @@ -139,9 +141,6 @@ tarfile: $(DISTNAME)/bzlib.h \ $(DISTNAME)/bzlib_private.h \ $(DISTNAME)/Makefile \ - $(DISTNAME)/manual.texi \ - $(DISTNAME)/manual.ps \ - $(DISTNAME)/manual.pdf \ $(DISTNAME)/LICENSE \ $(DISTNAME)/bzip2.1 \ $(DISTNAME)/bzip2.1.preformatted \ @@ -157,9 +156,12 @@ tarfile: $(DISTNAME)/sample2.bz2 \ $(DISTNAME)/sample3.bz2 \ $(DISTNAME)/dlltest.c \ - $(DISTNAME)/*.html \ + $(DISTNAME)/manual.html \ + $(DISTNAME)/manual.pdf \ + $(DISTNAME)/manual.ps \ $(DISTNAME)/README \ $(DISTNAME)/README.COMPILATION.PROBLEMS \ + $(DISTNAME)/README.XML.STUFF \ $(DISTNAME)/CHANGES \ $(DISTNAME)/libbz2.def \ $(DISTNAME)/libbz2.dsp \ @@ -175,18 +177,29 @@ tarfile: $(DISTNAME)/bzmore.1 \ $(DISTNAME)/bzgrep \ $(DISTNAME)/bzgrep.1 \ - $(DISTNAME)/Makefile-libbz2_so + $(DISTNAME)/Makefile-libbz2_so \ + $(DISTNAME)/bz-common.xsl \ + $(DISTNAME)/bz-fo.xsl \ + $(DISTNAME)/bz-html.xsl \ + $(DISTNAME)/bzip.css \ + $(DISTNAME)/entities.xml \ + $(DISTNAME)/manual.xml \ + $(DISTNAME)/format.pl \ + $(DISTNAME)/xmlproc.sh gzip -v $(DISTNAME).tar -# For rebuilding the manual from sources on my RedHat 7.2 box -manual: manual.ps manual.pdf manual.html +# For rebuilding the manual from sources on my SuSE 9.1 box -manual.ps: manual.texi - tex manual.texi - dvips -o manual.ps manual.dvi +MANUAL_SRCS= bz-common.xsl bz-fo.xsl bz-html.xsl bzip.css \ + entities.xml manual.xml -manual.pdf: manual.ps - ps2pdf manual.ps +manual: manual.html manual.ps manual.pdf -manual.html: manual.texi - texi2html -split_chapter manual.texi +manual.ps: $(MANUAL_SRCS) + ./xmlproc.sh -ps manual.xml + +manual.pdf: $(MANUAL_SRCS) + ./xmlproc.sh -pdf manual.xml + +manual.html: $(MANUAL_SRCS) + ./xmlproc.sh -html manual.xml diff --git a/contrib/bzip2/Makefile-libbz2_so b/contrib/bzip2/Makefile-libbz2_so index 4986fe2ad8a7..458c5a135e79 100644 --- a/contrib/bzip2/Makefile-libbz2_so +++ b/contrib/bzip2/Makefile-libbz2_so @@ -1,6 +1,6 @@ # This Makefile builds a shared version of the library, -# libbz2.so.1.0.2, with soname libbz2.so.1.0, +# libbz2.so.1.0.3, 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 @@ -9,7 +9,7 @@ SHELL=/bin/sh CC=gcc BIGFILES=-D_FILE_OFFSET_BITS=64 -CFLAGS=-fpic -fPIC -Wall -Winline -O2 -fomit-frame-pointer -fno-strength-reduce $(BIGFILES) +CFLAGS=-fpic -fPIC -Wall -Winline -O -g OBJS= blocksort.o \ huffman.o \ @@ -20,13 +20,13 @@ OBJS= blocksort.o \ bzlib.o all: $(OBJS) - $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.2 $(OBJS) - $(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.2 + $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.3 $(OBJS) + $(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.3 rm -f libbz2.so.1.0 - ln -s libbz2.so.1.0.2 libbz2.so.1.0 + ln -s libbz2.so.1.0.3 libbz2.so.1.0 clean: - rm -f $(OBJS) bzip2.o libbz2.so.1.0.2 libbz2.so.1.0 bzip2-shared + rm -f $(OBJS) bzip2.o libbz2.so.1.0.3 libbz2.so.1.0 bzip2-shared blocksort.o: blocksort.c $(CC) $(CFLAGS) -c blocksort.c diff --git a/contrib/bzip2/README b/contrib/bzip2/README index 07505d8f3d68..1aff4487e8c2 100644 --- a/contrib/bzip2/README +++ b/contrib/bzip2/README @@ -1,15 +1,15 @@ This is the README for bzip2, a block-sorting file compressor, version -1.0.2. This version is fully compatible with the previous public -releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0 and 1.0.1. +1.0.3. This version is fully compatible with the previous public +releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1 and 1.0.2. -bzip2-1.0.2 is distributed under a BSD-style license. For details, +bzip2-1.0.3 is distributed under a BSD-style license. For details, see the file LICENSE. Complete documentation is available in Postscript form (manual.ps), -PDF (manual.pdf, amazingly enough) or html (manual_toc.html). A -plain-text version of the manual page is available as bzip2.txt. -A statement about Y2K issues is now included in the file Y2K_INFO. +PDF (manual.pdf) or html (manual.html). A plain-text version of the +manual page is available as bzip2.txt. A statement about Y2K issues +is now included in the file Y2K_INFO. HOW TO BUILD -- UNIX @@ -78,8 +78,7 @@ importance. To validate bzip2, I used a modified version of Mark Nelson's churn program. Churn is an automated test driver which recursively traverses a directory structure, using bzip2 to compress and then decompress each file it encounters, and checking that the -decompressed data is the same as the original. There are more details -in Section 4 of the user guide. +decompressed data is the same as the original. @@ -119,9 +118,9 @@ DISCLAIMER: PATENTS: To the best of my knowledge, bzip2 does not use any patented - algorithms. However, I do not have the resources available to - carry out a full patent search. Therefore I cannot give any - guarantee of the above statement. + algorithms. However, I do not have the resources to carry out + a patent search. Therefore I cannot give any guarantee of the + above statement. End of legalities. @@ -153,22 +152,26 @@ WHAT'S NEW IN 1.0.2 ? See the CHANGES file. +WHAT'S NEW IN 1.0.3 ? + + See the CHANGES file. + I hope you find bzip2 useful. Feel free to contact me at - jseward@acm.org + jseward@bzip.org if you have any suggestions or queries. Many people mailed me with comments, suggestions and patches after the releases of bzip-0.15, -bzip-0.21, and bzip2 versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0 and 1.0.1, -and the changes in bzip2 are largely a result of this feedback. +bzip-0.21, and bzip2 versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1 and +1.0.2, and the changes in bzip2 are largely a result of this feedback. I thank you for your comments. At least for the time being, bzip2's "home" is (or can be reached via) -http://sources.redhat.com/bzip2. +http://www.bzip.org Julian Seward -jseward@acm.org +jseward@bzip.org -Cambridge, UK (and what a great town this is!) +Cambridge, UK. 18 July 1996 (version 0.15) 25 August 1996 (version 0.21) @@ -178,4 +181,5 @@ Cambridge, UK (and what a great town this is!) 8 June 1999 (bzip2, version 0.9.5) 4 Sept 1999 (bzip2, version 0.9.5d) 5 May 2000 (bzip2, version 1.0pre8) -30 December 2001 (bzip2, version 1.0.2pre1) \ No newline at end of file +30 December 2001 (bzip2, version 1.0.2pre1) +15 February 2005 (bzip2, version 1.0.3) diff --git a/contrib/bzip2/README.COMPILATION.PROBLEMS b/contrib/bzip2/README.COMPILATION.PROBLEMS index bd1822dffbd0..f1bc396b7652 100644 --- a/contrib/bzip2/README.COMPILATION.PROBLEMS +++ b/contrib/bzip2/README.COMPILATION.PROBLEMS @@ -1,11 +1,10 @@ -bzip2-1.0 should compile without problems on the vast majority of +bzip2-1.0.3 should compile without problems on the vast majority of platforms. Using the supplied Makefile, I've built and tested it -myself for x86-linux, sparc-solaris, alpha-linux, x86-cygwin32 and -alpha-tru64unix. With makefile.msc, Visual C++ 6.0 and nmake, you can -build a native Win32 version too. Large file support seems to work -correctly on at least alpha-tru64unix and x86-cygwin32 (on Windows -2000). +myself for x86-linux and x86_64-linux. With makefile.msc, Visual C++ +6.0 and nmake, you can build a native Win32 version too. Large file +support seems to work correctly on at least alpha-tru64unix and +x86-cygwin32 (on Windows 2000). When I say "large file" I mean a file of size 2,147,483,648 (2^31) bytes or above. Many older OSs can't handle files above this size, @@ -22,7 +21,7 @@ The technique of adding -D_FILE_OFFSET_BITS=64 to get large file support is, as far as I know, the Recommended Way to get correct large file support. For more details, see the Large File Support Specification, published by the Large File Summit, at - http://www.sas.com/standard/large.file/ + http://ftp.sas.com/standards/large.file As a general comment, if you get compilation errors which you think are related to large file support, try removing the above define from @@ -38,93 +37,3 @@ You can use the spewG.c program to generate huge files to test bzip2's large file support, if you are feeling paranoid. Be aware though that any compilation problems which affect bzip2 will also affect spewG.c, alas. - - -Known problems as of 1.0pre8: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -* HP/UX 10.20 and 11.00, using gcc (2.7.2.3 and 2.95.2): A large - number of warnings appear, including the following: - - /usr/include/sys/resource.h: In function `getrlimit': - /usr/include/sys/resource.h:168: - warning: implicit declaration of function `__getrlimit64' - /usr/include/sys/resource.h: In function `setrlimit': - /usr/include/sys/resource.h:170: - warning: implicit declaration of function `__setrlimit64' - - This would appear to be a problem with large file support, header - files and gcc. gcc may or may not give up at this point. If it - fails, you might be able to improve matters by adding - -D__STDC_EXT__=1 - to the BIGFILES variable in the Makefile (ie, change its definition - to - BIGFILES=-D_FILE_OFFSET_BITS=64 -D__STDC_EXT__=1 - - Even if gcc does produce a binary which appears to work (ie passes - its self-tests), you might want to test it to see if it works properly - on large files. - - -* HP/UX 10.20 and 11.00, using HP's cc compiler. - - No specific problems for this combination, except that you'll need to - specify the -Ae flag, and zap the gcc-specific stuff - -Wall -Winline -O2 -fomit-frame-pointer -fno-strength-reduce. - You should retain -D_FILE_OFFSET_BITS=64 in order to get large - file support -- which is reported to work ok for this HP/UX + cc - combination. - - -* SunOS 4.1.X. - - Amazingly, there are still people out there using this venerable old - banger. I shouldn't be too rude -- I started life on SunOS, and - it was a pretty darn good OS, way back then. Anyway: - - SunOS doesn't seem to have strerror(), so you'll have to use - perror(), perhaps by doing adding this (warning: UNTESTED CODE): - - char* strerror ( int errnum ) - { - if (errnum < 0 || errnum >= sys_nerr) - return "Unknown error"; - else - return sys_errlist[errnum]; - } - - Or you could comment out the relevant calls to strerror; they're - not mission-critical. Or you could upgrade to Solaris. Ha ha ha! - (what?? you think I've got Bad Attitude?) - - -* Making a shared library on Solaris. (Not really a compilation - problem, but many people ask ...) - - Firstly, if you have Solaris 8, either you have libbz2.so already - on your system, or you can install it from the Solaris CD. - - Secondly, be aware that there are potential naming conflicts - between the .so file supplied with Solaris 8, and the .so file - which Makefile-libbz2_so will make. Makefile-libbz2_so creates - a .so which has the names which I intend to be "official" as - of version 1.0.0 and onwards. Unfortunately, the .so in - Solaris 8 appeared before I decided on the final names, so - the two libraries are incompatible. We have since communicated - and I hope that the problems will have been solved in the next - version of Solaris, whenever that might appear. - - All that said: you might be able to get somewhere - by finding the line in Makefile-libbz2_so which says - - $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.2 $(OBJS) - - and replacing with - - $(CC) -G -shared -o libbz2.so.1.0.2 -h libbz2.so.1.0 $(OBJS) - - If gcc objects to the combination -fpic -fPIC, get rid of - the second one, leaving just "-fpic". - - -That's the end of the currently known compilation problems. diff --git a/contrib/bzip2/blocksort.c b/contrib/bzip2/blocksort.c index aba3efcd3121..33ec9f5dcb0e 100644 --- a/contrib/bzip2/blocksort.c +++ b/contrib/bzip2/blocksort.c @@ -8,7 +8,7 @@ This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. - Copyright (C) 1996-2002 Julian R Seward. All rights reserved. + Copyright (C) 1996-2005 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -42,7 +42,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. - jseward@acm.org + jseward@bzip.org bzip2/libbzip2 version 1.0 of 21 March 2000 This program is based on (at least) the work of: diff --git a/contrib/bzip2/bzip2.1 b/contrib/bzip2/bzip2.1 index 623435c24277..d2c066156837 100644 --- a/contrib/bzip2/bzip2.1 +++ b/contrib/bzip2/bzip2.1 @@ -1,7 +1,7 @@ .PU .TH bzip2 1 .SH NAME -bzip2, bunzip2 \- a block-sorting file compressor, v1.0.2 +bzip2, bunzip2 \- a block-sorting file compressor, v1.0.3 .br bzcat \- decompresses files to stdout .br @@ -405,19 +405,19 @@ 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.2 of +This manual page pertains to version 1.0.3 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 and 1.0.1, but with the following +0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1 and 1.0.2, 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. .I bzip2recover -versions prior to this one, 1.0.2, used 32-bit integers to represent -bit positions in compressed files, so it could not handle compressed -files more than 512 megabytes long. Version 1.0.2 and above uses +versions prior to 1.0.2 used 32-bit integers to represent +bit positions in compressed files, so they could not handle compressed +files more than 512 megabytes long. Versions 1.0.2 and above use 64-bit ints on some platforms which support them (GNU supported targets, and Windows). To establish whether or not bzip2recover was built with such a limitation, run it without arguments. In any event @@ -427,9 +427,9 @@ with MaybeUInt64 set to be an unsigned 64-bit integer. .SH AUTHOR -Julian Seward, jseward@acm.org. +Julian Seward, jsewardbzip.org. -http://sources.redhat.com/bzip2 +http://www.bzip.org The ideas embodied in .I bzip2 @@ -447,6 +447,7 @@ source distribution for pointers to sources of documentation. Christian von Roques encouraged me to look for faster sorting algorithms, so as to speed up compression. Bela Lubkin encouraged me to improve the worst-case compression performance. +Donna Robinson XMLised the documentation. The bz* scripts are derived from those of GNU gzip. Many people sent patches, helped with portability problems, lent machines, gave advice and were generally diff --git a/contrib/bzip2/bzip2.c b/contrib/bzip2/bzip2.c index 807f420aed6b..79f87a51986b 100644 --- a/contrib/bzip2/bzip2.c +++ b/contrib/bzip2/bzip2.c @@ -7,7 +7,7 @@ This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. - Copyright (C) 1996-2002 Julian R Seward. All rights reserved. + Copyright (C) 1996-2005 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -41,7 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. - jseward@acm.org + jseward@bzip.org bzip2/libbzip2 version 1.0 of 21 March 2000 This program is based on (at least) the work of: @@ -525,6 +525,7 @@ Bool uncompressStream ( FILE *zStream, FILE *stream ) UChar obuf[5000]; UChar unused[BZ_MAX_UNUSED]; Int32 nUnused; + void* unusedTmpV; UChar* unusedTmp; nUnused = 0; @@ -554,9 +555,10 @@ Bool uncompressStream ( FILE *zStream, FILE *stream ) } if (bzerr != BZ_STREAM_END) goto errhandler; - BZ2_bzReadGetUnused ( &bzerr, bzf, (void**)(&unusedTmp), &nUnused ); + BZ2_bzReadGetUnused ( &bzerr, bzf, &unusedTmpV, &nUnused ); if (bzerr != BZ_OK) panic ( "decompress:bzReadGetUnused" ); + unusedTmp = (UChar*)unusedTmpV; for (i = 0; i < nUnused; i++) unused[i] = unusedTmp[i]; BZ2_bzReadClose ( &bzerr, bzf ); @@ -639,6 +641,7 @@ Bool testStream ( FILE *zStream ) UChar obuf[5000]; UChar unused[BZ_MAX_UNUSED]; Int32 nUnused; + void* unusedTmpV; UChar* unusedTmp; nUnused = 0; @@ -662,9 +665,10 @@ Bool testStream ( FILE *zStream ) } if (bzerr != BZ_STREAM_END) goto errhandler; - BZ2_bzReadGetUnused ( &bzerr, bzf, (void**)(&unusedTmp), &nUnused ); + BZ2_bzReadGetUnused ( &bzerr, bzf, &unusedTmpV, &nUnused ); if (bzerr != BZ_OK) panic ( "test:bzReadGetUnused" ); + unusedTmp = (UChar*)unusedTmpV; for (i = 0; i < nUnused; i++) unused[i] = unusedTmp[i]; BZ2_bzReadClose ( &bzerr, bzf ); @@ -828,7 +832,7 @@ void panic ( Char* s ) "\n%s: PANIC -- internal consistency error:\n" "\t%s\n" "\tThis is a BUG. Please report it to me at:\n" - "\tjseward@acm.org\n", + "\tjseward@bzip.org\n", progName, s ); showFileNames(); cleanUpAndFail( 3 ); @@ -908,7 +912,7 @@ void mySIGSEGVorSIGBUScatcher ( IntNative n ) " The user's manual, Section 4.3, has more info on (1) and (2).\n" " \n" " If you suspect this is a bug in bzip2, or are unsure about (1)\n" - " or (2), feel free to report it to me at: jseward@acm.org.\n" + " or (2), feel free to report it to me at: jseward@bzip.org.\n" " Section 4.3 of the user's manual describes the info a useful\n" " bug report should have. If the manual is available on your\n" " system, please try and read it before mailing me. If you don't\n" @@ -931,7 +935,7 @@ void mySIGSEGVorSIGBUScatcher ( IntNative n ) " The user's manual, Section 4.3, has more info on (2) and (3).\n" " \n" " If you suspect this is a bug in bzip2, or are unsure about (2)\n" - " or (3), feel free to report it to me at: jseward@acm.org.\n" + " or (3), feel free to report it to me at: jseward@bzip.org.\n" " Section 4.3 of the user's manual describes the info a useful\n" " bug report should have. If the manual is available on your\n" " system, please try and read it before mailing me. If you don't\n" @@ -1674,7 +1678,7 @@ void license ( void ) "bzip2, a block-sorting file compressor. " "Version %s.\n" " \n" - " Copyright (C) 1996-2002 by Julian Seward.\n" + " Copyright (C) 1996-2005 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" diff --git a/contrib/bzip2/bzip2recover.c b/contrib/bzip2/bzip2recover.c index 286873b8c07b..5cd405dd4cb8 100644 --- a/contrib/bzip2/bzip2recover.c +++ b/contrib/bzip2/bzip2recover.c @@ -7,9 +7,9 @@ /*-- This program is bzip2recover, a program to attempt data salvage from damaged files created by the accompanying - bzip2-1.0 program. + bzip2-1.0.3 program. - Copyright (C) 1996-2002 Julian R Seward. All rights reserved. + Copyright (C) 1996-2005 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -43,8 +43,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. - jseward@acm.org - bzip2/libbzip2 version 1.0 of 21 March 2000 + jseward@bzip.org + bzip2/libbzip2 version 1.0.3 of 15 February 2005 --*/ /*-- @@ -345,7 +345,7 @@ Int32 main ( Int32 argc, Char** argv ) inFileName[0] = outFileName[0] = 0; fprintf ( stderr, - "bzip2recover 1.0.2: extracts blocks from damaged .bz2 files.\n" ); + "bzip2recover 1.0.3: extracts blocks from damaged .bz2 files.\n" ); if (argc != 2) { fprintf ( stderr, "%s: usage is `%s damaged_file_name'.\n", @@ -374,7 +374,7 @@ Int32 main ( Int32 argc, Char** argv ) if (strlen(argv[1]) >= BZ_MAX_FILENAME-20) { fprintf ( stderr, "%s: supplied filename is suspiciously (>= %d chars) long. Bye!\n", - progName, strlen(argv[1]) ); + progName, (int)strlen(argv[1]) ); exit(1); } diff --git a/contrib/bzip2/bzlib.c b/contrib/bzip2/bzlib.c index 7d1cb275f5b9..e9c1e879dece 100644 --- a/contrib/bzip2/bzlib.c +++ b/contrib/bzip2/bzlib.c @@ -8,7 +8,7 @@ This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. - Copyright (C) 1996-2002 Julian R Seward. All rights reserved. + Copyright (C) 1996-2005 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -42,7 +42,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. - jseward@acm.org + jseward@bzip.org bzip2/libbzip2 version 1.0 of 21 March 2000 This program is based on (at least) the work of: @@ -88,12 +88,12 @@ void BZ2_bz__AssertH__fail ( int errcode ) fprintf(stderr, "\n\nbzip2/libbzip2: internal error number %d.\n" "This is a bug in bzip2/libbzip2, %s.\n" - "Please report it to me at: jseward@acm.org. If this happened\n" + "Please report it to me at: jseward@bzip.org. If this happened\n" "when you were using some program which uses libbzip2 as a\n" "component, you should also report this bug to the author(s)\n" "of that program. Please make an effort to report this bug;\n" "timely and accurate bug reports eventually lead to higher\n" - "quality software. Thanks. Julian Seward, 30 December 2001.\n\n", + "quality software. Thanks. Julian Seward, 15 February 2005.\n\n", errcode, BZ2_bzlibVersion() ); @@ -574,8 +574,11 @@ int BZ_API(BZ2_bzDecompressInit) /*---------------------------------------------------*/ +/* Return True iff data corruption is discovered. + Returns False if there is no problem. +*/ static -void unRLE_obuf_to_output_FAST ( DState* s ) +Bool unRLE_obuf_to_output_FAST ( DState* s ) { UChar k1; @@ -584,7 +587,7 @@ void unRLE_obuf_to_output_FAST ( DState* s ) while (True) { /* try to finish existing run */ while (True) { - if (s->strm->avail_out == 0) return; + if (s->strm->avail_out == 0) return False; if (s->state_out_len == 0) break; *( (UChar*)(s->strm->next_out) ) = s->state_out_ch; BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); @@ -594,10 +597,13 @@ void unRLE_obuf_to_output_FAST ( DState* s ) s->strm->total_out_lo32++; if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; } - + /* can a new run be started? */ - if (s->nblock_used == s->save_nblock+1) return; + if (s->nblock_used == s->save_nblock+1) return False; + /* Only caused by corrupt data stream? */ + if (s->nblock_used > s->save_nblock+1) + return True; s->state_out_len = 1; s->state_out_ch = s->k0; @@ -667,6 +673,10 @@ void unRLE_obuf_to_output_FAST ( DState* s ) cs_avail_out--; } } + /* Only caused by corrupt data stream? */ + if (c_nblock_used > s_save_nblockPP) + return True; + /* can a new run be started? */ if (c_nblock_used == s_save_nblockPP) { c_state_out_len = 0; goto return_notr; @@ -712,6 +722,7 @@ void unRLE_obuf_to_output_FAST ( DState* s ) s->strm->avail_out = cs_avail_out; /* end save */ } + return False; } @@ -732,8 +743,11 @@ __inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab ) /*---------------------------------------------------*/ +/* Return True iff data corruption is discovered. + Returns False if there is no problem. +*/ static -void unRLE_obuf_to_output_SMALL ( DState* s ) +Bool unRLE_obuf_to_output_SMALL ( DState* s ) { UChar k1; @@ -742,7 +756,7 @@ void unRLE_obuf_to_output_SMALL ( DState* s ) while (True) { /* try to finish existing run */ while (True) { - if (s->strm->avail_out == 0) return; + if (s->strm->avail_out == 0) return False; if (s->state_out_len == 0) break; *( (UChar*)(s->strm->next_out) ) = s->state_out_ch; BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); @@ -754,8 +768,11 @@ void unRLE_obuf_to_output_SMALL ( DState* s ) } /* can a new run be started? */ - if (s->nblock_used == s->save_nblock+1) return; - + if (s->nblock_used == s->save_nblock+1) return False; + + /* Only caused by corrupt data stream? */ + if (s->nblock_used > s->save_nblock+1) + return True; s->state_out_len = 1; s->state_out_ch = s->k0; @@ -788,7 +805,7 @@ void unRLE_obuf_to_output_SMALL ( DState* s ) while (True) { /* try to finish existing run */ while (True) { - if (s->strm->avail_out == 0) return; + if (s->strm->avail_out == 0) return False; if (s->state_out_len == 0) break; *( (UChar*)(s->strm->next_out) ) = s->state_out_ch; BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); @@ -800,7 +817,11 @@ void unRLE_obuf_to_output_SMALL ( DState* s ) } /* can a new run be started? */ - if (s->nblock_used == s->save_nblock+1) return; + if (s->nblock_used == s->save_nblock+1) return False; + + /* Only caused by corrupt data stream? */ + if (s->nblock_used > s->save_nblock+1) + return True; s->state_out_len = 1; s->state_out_ch = s->k0; @@ -830,6 +851,7 @@ void unRLE_obuf_to_output_SMALL ( DState* s ) /*---------------------------------------------------*/ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) { + Bool corrupt; DState* s; if (strm == NULL) return BZ_PARAM_ERROR; s = strm->state; @@ -840,12 +862,13 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR; if (s->state == BZ_X_OUTPUT) { if (s->smallDecompress) - unRLE_obuf_to_output_SMALL ( s ); else - unRLE_obuf_to_output_FAST ( s ); + corrupt = unRLE_obuf_to_output_SMALL ( s ); else + corrupt = unRLE_obuf_to_output_FAST ( s ); + if (corrupt) return BZ_DATA_ERROR; if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) { BZ_FINALISE_CRC ( s->calculatedBlockCRC ); if (s->verbosity >= 3) - VPrintf2 ( " {0x%x, 0x%x}", s->storedBlockCRC, + VPrintf2 ( " {0x%08x, 0x%08x}", s->storedBlockCRC, s->calculatedBlockCRC ); if (s->verbosity >= 2) VPrintf0 ( "]" ); if (s->calculatedBlockCRC != s->storedBlockCRC) @@ -863,7 +886,7 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) Int32 r = BZ2_decompress ( s ); if (r == BZ_STREAM_END) { if (s->verbosity >= 3) - VPrintf2 ( "\n combined CRCs: stored = 0x%x, computed = 0x%x", + VPrintf2 ( "\n combined CRCs: stored = 0x%08x, computed = 0x%08x", s->storedCombinedCRC, s->calculatedCombinedCRC ); if (s->calculatedCombinedCRC != s->storedCombinedCRC) return BZ_DATA_ERROR; diff --git a/contrib/bzip2/bzlib.h b/contrib/bzip2/bzlib.h index 9ac43a169da5..323724394a29 100644 --- a/contrib/bzip2/bzlib.h +++ b/contrib/bzip2/bzlib.h @@ -8,7 +8,7 @@ This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. - Copyright (C) 1996-2002 Julian R Seward. All rights reserved. + Copyright (C) 1996-2005 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -42,7 +42,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. - jseward@acm.org + jseward@bzip.org bzip2/libbzip2 version 1.0 of 21 March 2000 This program is based on (at least) the work of: @@ -110,8 +110,10 @@ typedef #define BZ_EXPORT #endif +#ifndef BZ_NO_STDIO /* Need a definitition for FILE */ #include +#endif #ifdef _WIN32 # include diff --git a/contrib/bzip2/bzlib_private.h b/contrib/bzip2/bzlib_private.h index ff973c3bfd03..ca76fe62b3bc 100644 --- a/contrib/bzip2/bzlib_private.h +++ b/contrib/bzip2/bzlib_private.h @@ -8,7 +8,7 @@ This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. - Copyright (C) 1996-2002 Julian R Seward. All rights reserved. + Copyright (C) 1996-2005 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -42,7 +42,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. - jseward@acm.org + jseward@bzip.org bzip2/libbzip2 version 1.0 of 21 March 2000 This program is based on (at least) the work of: @@ -76,7 +76,7 @@ /*-- General stuff. --*/ -#define BZ_VERSION "1.0.2, 30-Dec-2001" +#define BZ_VERSION "1.0.3, 15-Feb-2005" typedef char Char; typedef unsigned char Bool; diff --git a/contrib/bzip2/compress.c b/contrib/bzip2/compress.c index 56501c115533..7e0c29155abd 100644 --- a/contrib/bzip2/compress.c +++ b/contrib/bzip2/compress.c @@ -8,7 +8,7 @@ This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. - Copyright (C) 1996-2002 Julian R Seward. All rights reserved. + Copyright (C) 1996-2005 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -42,7 +42,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. - jseward@acm.org + jseward@bzip.org bzip2/libbzip2 version 1.0 of 21 March 2000 This program is based on (at least) the work of: @@ -488,9 +488,11 @@ void sendMTFValues ( EState* s ) /*-- Recompute the tables based on the accumulated frequencies. --*/ + /* maxLen was changed from 20 to 17 in bzip2-1.0.3. See + comment in huffman.c for details. */ for (t = 0; t < nGroups; t++) BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]), - alphaSize, 20 ); + alphaSize, 17 /*20*/ ); } @@ -527,7 +529,7 @@ void sendMTFValues ( EState* s ) if (s->len[t][i] > maxLen) maxLen = s->len[t][i]; if (s->len[t][i] < minLen) minLen = s->len[t][i]; } - AssertH ( !(maxLen > 20), 3004 ); + AssertH ( !(maxLen > 17 /*20*/ ), 3004 ); AssertH ( !(minLen < 1), 3005 ); BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]), minLen, maxLen, alphaSize ); @@ -651,8 +653,8 @@ void BZ2_compressBlock ( EState* s, Bool is_last_block ) if (s->blockNo > 1) s->numZ = 0; if (s->verbosity >= 2) - VPrintf4( " block %d: crc = 0x%8x, " - "combined CRC = 0x%8x, size = %d\n", + VPrintf4( " block %d: crc = 0x%08x, " + "combined CRC = 0x%08x, size = %d\n", s->blockNo, s->blockCRC, s->combinedCRC, s->nblock ); BZ2_blockSort ( s ); @@ -703,7 +705,7 @@ void BZ2_compressBlock ( EState* s, Bool is_last_block ) bsPutUChar ( s, 0x50 ); bsPutUChar ( s, 0x90 ); bsPutUInt32 ( s, s->combinedCRC ); if (s->verbosity >= 2) - VPrintf1( " final combined CRC = 0x%x\n ", s->combinedCRC ); + VPrintf1( " final combined CRC = 0x%08x\n ", s->combinedCRC ); bsFinishWrite ( s ); } } diff --git a/contrib/bzip2/crctable.c b/contrib/bzip2/crctable.c index b16746ae1942..b6dadfc62f29 100644 --- a/contrib/bzip2/crctable.c +++ b/contrib/bzip2/crctable.c @@ -8,7 +8,7 @@ This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. - Copyright (C) 1996-2002 Julian R Seward. All rights reserved. + Copyright (C) 1996-2005 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -42,7 +42,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. - jseward@acm.org + jseward@bzip.org bzip2/libbzip2 version 1.0 of 21 March 2000 This program is based on (at least) the work of: diff --git a/contrib/bzip2/decompress.c b/contrib/bzip2/decompress.c index e9213473acf4..81c3d2cc3f44 100644 --- a/contrib/bzip2/decompress.c +++ b/contrib/bzip2/decompress.c @@ -8,7 +8,7 @@ This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. - Copyright (C) 1996-2002 Julian R Seward. All rights reserved. + Copyright (C) 1996-2005 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -42,7 +42,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. - jseward@acm.org + jseward@bzip.org bzip2/libbzip2 version 1.0 of 21 March 2000 This program is based on (at least) the work of: @@ -524,17 +524,23 @@ Int32 BZ2_decompress ( DState* s ) if (s->origPtr < 0 || s->origPtr >= nblock) RETURN(BZ_DATA_ERROR); + /*-- Set up cftab to facilitate generation of T^(-1) --*/ + 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]; + 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); + } + } + s->state_out_len = 0; s->state_out_ch = 0; BZ_INITIALISE_CRC ( s->calculatedBlockCRC ); s->state = BZ_X_OUTPUT; if (s->verbosity >= 2) VPrintf0 ( "rt+rld" ); - /*-- Set up cftab to facilitate generation of T^(-1) --*/ - 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]; - if (s->smallDecompress) { /*-- Make a copy of cftab, used in generation of T --*/ diff --git a/contrib/bzip2/huffman.c b/contrib/bzip2/huffman.c index 293095c170c0..5bf190be9a14 100644 --- a/contrib/bzip2/huffman.c +++ b/contrib/bzip2/huffman.c @@ -8,7 +8,7 @@ This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. - Copyright (C) 1996-2002 Julian R Seward. All rights reserved. + Copyright (C) 1996-2005 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -42,7 +42,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. - jseward@acm.org + jseward@bzip.org bzip2/libbzip2 version 1.0 of 21 March 2000 This program is based on (at least) the work of: @@ -162,7 +162,24 @@ void BZ2_hbMakeCodeLengths ( UChar *len, if (! tooLong) break; - for (i = 1; i < alphaSize; i++) { + /* 17 Oct 04: keep-going condition for the following loop used + to be 'i < alphaSize', which missed the last element, + theoretically leading to the possibility of the compressor + looping. However, this count-scaling step is only needed if + one of the generated Huffman code words is longer than + maxLen, which up to and including version 1.0.2 was 20 bits, + which is extremely unlikely. In version 1.0.3 maxLen was + changed to 17 bits, which has minimal effect on compression + ratio, but does mean this scaling step is used from time to + time, enough to verify that it works. + + This means that bzip2-1.0.3 and later will only produce + Huffman codes with a maximum length of 17 bits. However, in + order to preserve backwards compatibility with bitstreams + produced by versions pre-1.0.3, the decompressor must still + handle lengths of up to 20. */ + + for (i = 1; i <= alphaSize; i++) { j = weight[i] >> 8; j = 1 + (j / 2); weight[i] = j << 8; diff --git a/contrib/bzip2/randtable.c b/contrib/bzip2/randtable.c index 5c922e94f3c5..940462d693d6 100644 --- a/contrib/bzip2/randtable.c +++ b/contrib/bzip2/randtable.c @@ -8,7 +8,7 @@ This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. - Copyright (C) 1996-2002 Julian R Seward. All rights reserved. + Copyright (C) 1996-2005 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -42,7 +42,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. - jseward@acm.org + jseward@bzip.org bzip2/libbzip2 version 1.0 of 21 March 2000 This program is based on (at least) the work of: diff --git a/contrib/bzip2/sample1.bz2.uu b/contrib/bzip2/sample1.bz2.uu index 544568031af1..7095c0d334e7 100644 --- a/contrib/bzip2/sample1.bz2.uu +++ b/contrib/bzip2/sample1.bz2.uu @@ -1,4 +1,4 @@ -begin 644 sample1.bz2 +begin 640 sample1.bz2 M0EIH,3%!62936``^"5D```4[8=N[8K7,-JP,#+WT`WUMF`[!Z#H>Z]G#Z!`$ M``&]F(!NO=V[[M9NCTWNY[8+SDJPX]LV]K.-S+;KAZ-ZL2V8*;.;77MW;VVY diff --git a/contrib/bzip2/sample1.ref.gz.uu b/contrib/bzip2/sample1.ref.gz.uu index 473cdec28181..fd23d6bc2368 100644 --- a/contrib/bzip2/sample1.ref.gz.uu +++ b/contrib/bzip2/sample1.ref.gz.uu @@ -1,5 +1,5 @@ -begin 644 sample1.ref.gz -M'XL("/:]F#4"`W-A;7!L93$NA,_$ST0=\,%= M^1&7:'60%:P"]4'=6Q4!E2M>4'%U5UVKURO*Y;X_W_>=&]\P diff --git a/contrib/bzip2/sample2.bz2.uu b/contrib/bzip2/sample2.bz2.uu index b0610ea63c91..b1a7134201e5 100644 --- a/contrib/bzip2/sample2.bz2.uu +++ b/contrib/bzip2/sample2.bz2.uu @@ -1,4 +1,4 @@ -begin 644 sample2.bz2 +begin 640 sample2.bz2 M0EIH,C%!629367PQR6$!@_U_____________________________________ M________X3T-[WV#SN>48``!H*!H`-``'3:NO$JCVP/N!K+L'U2AE M@`!.QH[YW>@&]ZXY```0:`^@``,G'WQSWQ[NC('@`0T7L!W84*!XU@`/30*N diff --git a/contrib/bzip2/sample2.ref.gz.uu b/contrib/bzip2/sample2.ref.gz.uu index 10291f930611..167bd6f71bdb 100644 --- a/contrib/bzip2/sample2.ref.gz.uu +++ b/contrib/bzip2/sample2.ref.gz.uu @@ -1,5 +1,5 @@ -begin 644 sample2.ref.gz -M'XL("/B]F#4"`W-A;7!L93(NX1)(!DVDX@UW=4SY717#5W=F4P@""XL2L8T!?44&2#L/(`@"(*, M+`HJH.S*PR(*@H`R@DL0?%#@/"?-_W?OP4DNZN6WKPBU87N[XI5>!/TRY1JZE9UN&;!6ZH,60K?O=56)J;1@ diff --git a/contrib/bzip2/sample3.ref.gz.uu b/contrib/bzip2/sample3.ref.gz.uu index e087f833216a..b9353e5c43d4 100644 --- a/contrib/bzip2/sample3.ref.gz.uu +++ b/contrib/bzip2/sample3.ref.gz.uu @@ -1,5 +1,5 @@ -begin 644 sample3.ref.gz -M'XL("$_07C<"`W-A;7!L93,N4$"`)T;M%]+Z!F +begin 640 sample3.ref.gz +M'XL("'K+9T$"`W-A;7!L93,N4$"`)T;M%]+Z!F MZ-B(8P>2@S:W'R7HNB=XBP=1$#\E_9KF%N.\9/0U_YXSO^;ULCSC]U9[<8KX M.<9S>_2>]>M5U);+.-0LK[Z8]V/V%G]>)_N44;/ML8WO^OV.5I[M&*7?]O%YB)9YC7O=QAZ:M[4L