* [Caml-list] Cryptokit.Zlib uncompressing fails to terminate (fwd)
@ 2004-10-17 2:53 malc
2004-10-17 11:10 ` Nicolas Cannasse
2004-11-02 16:22 ` [Caml-list] Cryptokit.Zlib uncompressing fails to terminate (fwd) (Patch) malc
0 siblings, 2 replies; 4+ messages in thread
From: malc @ 2004-10-17 2:53 UTC (permalink / raw)
To: caml-list
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 ----------
<snip>
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.
Sincerely,
malc
--
mailto:malc@pulsesoft.com
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Cryptokit.Zlib uncompressing fails to terminate (fwd)
2004-10-17 2:53 [Caml-list] Cryptokit.Zlib uncompressing fails to terminate (fwd) malc
@ 2004-10-17 11:10 ` Nicolas Cannasse
2004-11-02 16:22 ` [Caml-list] Cryptokit.Zlib uncompressing fails to terminate (fwd) (Patch) malc
1 sibling, 0 replies; 4+ messages in thread
From: Nicolas Cannasse @ 2004-10-17 11:10 UTC (permalink / raw)
To: malc, caml-list
> 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.
While waiting the problem is fixed, you might use ExtLib "Unzip" module that
provides a pure ocaml "inflate" algorithm implementation ( aka zlib
decompression ). Speed is "only" around 2 to 3 times slower than zlib.
Nicolas Cannasse
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Cryptokit.Zlib uncompressing fails to terminate (fwd) (Patch)
2004-10-17 2:53 [Caml-list] Cryptokit.Zlib uncompressing fails to terminate (fwd) malc
2004-10-17 11:10 ` Nicolas Cannasse
@ 2004-11-02 16:22 ` malc
2004-11-16 10:17 ` [Caml-list] Cryptokit.Zlib uncompressing fails to terminate (fwd) (Another Patch) malc
1 sibling, 1 reply; 4+ messages in thread
From: malc @ 2004-11-02 16:22 UTC (permalink / raw)
To: caml-list
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 ----------
> <snip>
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Cryptokit.Zlib uncompressing fails to terminate (fwd) (Another Patch)
2004-11-02 16:22 ` [Caml-list] Cryptokit.Zlib uncompressing fails to terminate (fwd) (Patch) malc
@ 2004-11-16 10:17 ` malc
0 siblings, 0 replies; 4+ messages in thread
From: malc @ 2004-11-16 10:17 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-11-16 10:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-17 2:53 [Caml-list] Cryptokit.Zlib uncompressing fails to terminate (fwd) malc
2004-10-17 11:10 ` Nicolas Cannasse
2004-11-02 16:22 ` [Caml-list] Cryptokit.Zlib uncompressing fails to terminate (fwd) (Patch) malc
2004-11-16 10:17 ` [Caml-list] Cryptokit.Zlib uncompressing fails to terminate (fwd) (Another Patch) malc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox