From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 75155BC28 for ; Tue, 16 Nov 2004 11:17:09 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iAGAH9cX015056 for ; Tue, 16 Nov 2004 11:17:09 +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 LAA27913 for ; Tue, 16 Nov 2004 11:17:08 +0100 (MET) Received: from comtv.ru (mail.comtv.ru [217.10.32.17]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iAGAH7hR027469 for ; Tue, 16 Nov 2004 11:17:08 +0100 Received: from av1474.oops ([10.0.66.9] verified) by comtv.ru (CommuniGate Pro SMTP 4.1.8) with ESMTP id 45184238 for caml-list@inria.fr; Tue, 16 Nov 2004 13:17:06 +0300 Date: Tue, 16 Nov 2004 13:17:28 +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) (Another Patch) In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Miltered: at nez-perce with ID 4199D3A5.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 4199D3A3.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 zlib:01 buffer:01 ofs:01 ofs:01 buffer:01 mli:01 mli:01 pulsesoft:01 exception:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.0 X-Spam-Level: Hello, Previous patch for Cryptokit's Zlib was flawed (it did fix the original problem while, on the other hand introducing another and much bigger one) Here is another attempt (also thanks to David MENTRE for noticing a nasty typo in comments): diff -ur cryptokit-1.2-orig/cryptokit.ml cryptokit-1.2/cryptokit.ml --- cryptokit-1.2-orig/cryptokit.ml Thu Jul 10 17:37:38 2003 +++ cryptokit-1.2/cryptokit.ml Tue Nov 16 12:35:16 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,14 @@ 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 && not (used_in = len) + 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 cryptokit-1.2-orig/cryptokit.mli cryptokit-1.2/cryptokit.mli --- cryptokit-1.2-orig/cryptokit.mli Thu Jul 10 17:37:38 2003 +++ cryptokit-1.2/cryptokit.mli Tue Nov 16 13:13:26 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 handle *) exception Error of error (** Exception raised by functions in this library -- mailto:malc@pulsesoft.com