From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id C2AB3BC29 for ; Tue, 2 Nov 2004 17:22:35 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iA2GMZ6E016338 for ; Tue, 2 Nov 2004 17:22:35 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA23153 for ; Tue, 2 Nov 2004 17:22:34 +0100 (MET) Received: from comtv.ru (comtv.ru [217.10.32.4]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iA2GMXos016333 for ; Tue, 2 Nov 2004 17:22:34 +0100 Received: from av1474.oops ([10.0.66.9] verified) by comtv.ru (CommuniGate Pro SMTP 4.1.8) with ESMTP id 43668392 for caml-list@inria.fr; Tue, 02 Nov 2004 19:22:33 +0300 Date: Tue, 2 Nov 2004 19:22:20 +0300 (MSK) From: malc X-X-Sender: malc@home.oyster.ru To: caml-list@inria.fr Subject: Re: [Caml-list] Cryptokit.Zlib uncompressing fails to terminate (fwd) (Patch) In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at concorde with ID 4187B44B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 4187B44A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; malc:01 malc:01 pulsesoft:01 caml-list:01 zlib:01 terminate:01 wrote:01 zlib:01 terminate:01 tgz:01 makefile:01 ocaml:01 mnt:01 mnt:01 buffer:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: On Sun, 17 Oct 2004, malc wrote: > Hello, > > I have been unable to contact Xavier Leroy directly, so im reposting this > message here. Few more words about the stream that takes uncompress into > an endless loop, it is %100 valid zlib compressed data with 2 additional > (gzip's crc and length) words at the end. > > ---------- Forwarded message ---------- > > Hello Xavier, > > > > I noticed that uncompressing partially valid stream with > Cryptokit.Zlib.uncompress() fails to terminate. > http://www.boblycat.org/~malc/fail.tgz (489 bytes) > Contains minimal testcase (Makefile + OCaml source) > > I would apreciate any info on the subject. Following "fixes" it. diff -ur /mnt/big/npf/incoming/caml/cryptokit-1.2/cryptokit.ml /mnt/big/npf/bld/cryptokit-1.2/cryptokit.ml --- /mnt/big/npf/incoming/caml/cryptokit-1.2/cryptokit.ml Thu Jul 10 17:37:38 2003 +++ /mnt/big/npf/bld/cryptokit-1.2/cryptokit.ml Tue Nov 2 19:18:41 2004 @@ -33,6 +33,7 @@ | No_entropy_source | Entropy_source_closed | Compression_not_supported + | Input_buffer_to_big exception Error of error @@ -2029,12 +2030,13 @@ method put_substring src ofs len = if len > 0 then begin self#ensure_capacity 64; - let (_, used_in, used_out) = + let (finished, used_in, used_out) = inflate zs src ofs len obuf oend (String.length obuf - oend) Z_SYNC_FLUSH in oend <- oend + used_out; + if finished then raise (Error Input_buffer_to_big); if used_in < len then self#put_substring src (ofs + used_in) (len - used_in) end diff -ur /mnt/big/npf/incoming/caml/cryptokit-1.2/cryptokit.mli /mnt/big/npf/bld/cryptokit-1.2/cryptokit.mli --- /mnt/big/npf/incoming/caml/cryptokit-1.2/cryptokit.mli Thu Jul 10 17:37:38 2003 +++ /mnt/big/npf/bld/cryptokit-1.2/cryptokit.mli Tue Nov 2 19:17:42 2004 @@ -922,6 +922,9 @@ (** End of file on a device or EGD entropy source. *) | Compression_not_supported (** The data compression functions are not available. *) + | Input_buffer_to_big + (** More data has been passed to a function than it can + gracefully hanlde *) exception Error of error (** Exception raised by functions in this library -- mailto:malc@pulsesoft.com