Summary

sha2 digest procedures break when attempt to encode #f

Metadata

Attachments

Description

 ~$ /usr/local/chicken-4.3.0/bin/csi -n
 
 CHICKEN
 (c)2008-2009 The Chicken Team
 (c)2000-2007 Felix L. Winkelmann
 Version 4.3.0
 linux-unix-gnu-x86 [ manyargs dload ptables ]
 compiled 2009-12-15 on dellito (Linux)
 
 #;1> (use sha2)
 ; loading /usr/local/chicken-4.3.0/lib/chicken/4/sha2.import.so ...
 ; loading /usr/local/chicken-4.3.0/lib/chicken/4/chicken.import.so ...
 ; loading /usr/local/chicken-4.3.0/lib/chicken/4/scheme.import.so ...
 ; loading /usr/local/chicken-4.3.0/lib/chicken/4/foreign.import.so ...
 ; loading /usr/local/chicken-4.3.0/lib/chicken/4/message-digest.import.so ...
 ; loading /usr/local/chicken-4.3.0/lib/chicken/4/lolevel.import.so ...
 ; loading /usr/local/chicken-4.3.0/lib/chicken/4/srfi-1.import.so ...
 ; loading /usr/local/chicken-4.3.0/lib/chicken/4/srfi-4.import.so ...
 ; loading /usr/local/chicken-4.3.0/lib/chicken/4/srfi-13.import.so ...
 ; loading /usr/local/chicken-4.3.0/lib/chicken/4/srfi-69.import.so ...
 ; loading /usr/local/chicken-4.3.0/lib/chicken/4/miscmacros.import.so ...
 ; loading /usr/local/chicken-4.3.0/lib/chicken/4/type-checks.import.so ...
 ; loading /usr/local/chicken-4.3.0/lib/chicken/4/type-errors.import.so ...
 ; loading /usr/local/chicken-4.3.0/lib/chicken/4/data-structures.import.so ...
 ; loading /usr/local/chicken-4.3.0/lib/chicken/4/sha2.so ...
 ; loading /usr/local/chicken-4.3.0/lib/chicken/4/message-digest.so ...
 ; loading /usr/local/chicken-4.3.0/lib/chicken/4/type-checks.so ...
 ; loading /usr/local/chicken-4.3.0/lib/chicken/4/type-errors.so ...
 #;2> (sha256-digest #f)
 csi: sha2-base.c:536: SHA256_Update: Assertion `context != (SHA256_CTX*)0 && data != (sha2_byte*)0' failed.
 Aborted

The same behavior has been observed for sha384-digest and sha512-digest}. They make the interpreter abort.

Changes and comments

[2010-03-11 10:33:12 UTC] Milestone 4.4.0 deleted

[2010-04-08 19:19:08 UTC] mario changed status from new to assigned

[2010-04-08 19:19:08 UTC] mario set owner to daishi

[2010-04-08 19:19:08 UTC] mario set milestone to 4.5.0

[2010-04-08 19:19:08 UTC] mario wrote:

I've attached a patch which implements a (maybe crude) fix. Basically, all the exported procedures which expect an argument check if it is a string. If it is not a string, raise an error indicating that an string is expected.

[2010-04-08 19:32:53 UTC] mario attached sha2-string-arg.diff (description=Using ##sys#check-string)

[2010-04-22 02:38:58 UTC] mario changed status from assigned to closed

[2010-04-22 02:38:58 UTC] mario set resolution to fixed

[2010-04-22 02:38:58 UTC] mario wrote:

I've contacted Daishi and he said the patch looks ok. He asked me to apply it. So I did it and released version 2.0.1.

[2010-05-26 22:44:12 UTC] zbigniew wrote:

Unfortunately this breaks the ability of sha2 to digest any object other than strings such as blobs, srfi-4 vectors and even user-defined objects.

Fixed the underlying problem in message-digest 2.0.3, which was that a length of -1 was being returned to digest procedures that didn't expect it, causing a segfault. Now it signals an error. So sha2 can safely digest any object again.