Re: qforeign-0.65: Bzip2: decompress hangs if data ends prematurely

2001-10-25 Thread Marcin 'Qrczak' Kowalczyk

Thu, 25 Oct 2001 12:06:53 +0200 (CEST), Michael Marte 
<[EMAIL PROTECTED]> pisze:

> I found that decompress hangs if data ends prematurely, i.e.
> 
>   do
>   content <- readFile fp
>   doSomething (Bzip2.decompress content)
> 
> does not terminate in this case.

Try this patch (sorry, untested):

--- examples/Bzip2.hsc~ Mon Jun 11 23:19:50 2001
+++ examples/Bzip2.hsc  Thu Oct 25 17:55:19 2001
@@ -169,6 +169,7 @@
 let blockIn = take blockSize input
 ok <- decompressBlock strm blockIn blockSize
 case ok of
+RunOk 0  []   -> ioError (userError "bzip2: premature end of 
+compressed data")
 RunOk inSize blockOut -> liftM (blockOut++) $ unsafeInterleaveIO $
  decompressLoop strm (drop inSize input)
 StreamEnd output  -> return output

It's in CVS at SourceForge now.

-- 
 __("<  Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/
  ^^  SYGNATURA ZASTÊPCZA
QRCZAK


___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



qforeign-0.65: Bzip2: decompress hangs if data ends prematurely

2001-10-25 Thread Michael Marte

Hello *,

I found that decompress hangs if data ends prematurely,
i.e.

do
content <- readFile fp
doSomething (Bzip2.decompress content)

does not terminate in this case.
Data that is corrupt in some other way (for example, decompressing
a file that has not been generated with bzip2) is detected and
an exception is thrown.

Michael





___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users