This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Don't silently ignore corrupt bz2 files


On Thu, Nov 04, 2010 at 07:41:06PM +0000, Jon TURNEY wrote:
>
>As I discovered today whilst trying to test some other modifications to
>setup.exe, it currently silently decompresses a corrupt setup.bz2 into a zero
>length file.
>
>This should only cause problems if signature checking is disabled, or if the
>bz2 file got corrupted before it was signed.
>
>Patch attached.

>From a905bdbc2d61d375927c98f65e68b69f220fcffb Mon Sep 17 00:00:00 2001
>From: Jon TURNEY <jon.turney@dronecode.org.uk>
>Date: Thu, 4 Nov 2010 18:34:13 +0000
>Subject: [PATCH] Don't silently ignore corrupt bz2 files
>
>(This should only be a problem when either signatures are ignored,
>or the setup.bz2 is corrupted before being signed)
>
>Return 0 indicating EOF when decompressing bz, after bzDecompress returns
>BZ_STREAM_END, rather than continue to try to call bzDecompress beyond the
>end of the compressed data, generating a BZ_SEQUENCE_ERROR.
>
>Detect if an error occurred decompressing the ini file, and report it.
>---
> ChangeLog      |   10 ++++++++++
> compress_bz.cc |    4 ++++
> compress_bz.h  |    1 +
> ini.cc         |   10 +++++-----
> 4 files changed, 20 insertions(+), 5 deletions(-)
>
>diff --git a/ChangeLog b/ChangeLog
>index 8448885..d8193ab 100644
>--- a/ChangeLog
>+++ b/ChangeLog
>@@ -1,3 +1,13 @@
>+2010-11-04 Jon TURNEY <jon.turney@dronecode.org.uk>
>+
>+	* compress_bz.h (compress): Add endReached flag.
>+	* compress_bz.cc (read, compress_bz): Use endReached flag to return 0
>+	for a read when EOF has been reached, after BZ2_bzDecompress returns
>+	BZ_STREAM_END, rather than continue to try to call BZ2_bzDecompress
>+	beyond the end of the compressed data, generating a BZ_SEQUENCE_ERROR.
>+	* ini.cc (do_remote_ini): Now that bz2_stream doesn't always have a
>+	spurious error, detect and report if an error occurred decompressing.
>+

Please don't send ChangeLog's as diffs but otherwise, this looks good.  Please
check in.

cgf


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]