Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#163 closed defect (fixed)

sha2 digest procedures break when attempt to encode #f

Reported by: Mario Domenech Goulart Owned by: daishi
Priority: critical Milestone: 4.5.0
Component: extensions Version: 4.3.x
Keywords: sha2 Cc:
Estimated difficulty:

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.

Attachments (1)

sha2-string-arg.diff (1.5 KB) - added by Mario Domenech Goulart 14 years ago.
Using ##sys#check-string

Download all attachments as: .zip

Change History (5)

comment:1 Changed 14 years ago by (none)

Milestone 4.4.0 deleted

comment:2 Changed 14 years ago by Mario Domenech Goulart

Milestone: 4.5.0
Owner: set to daishi
Status: newassigned

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.

Changed 14 years ago by Mario Domenech Goulart

Attachment: sha2-string-arg.diff added

Using ##sys#check-string

comment:3 Changed 14 years ago by Mario Domenech Goulart

Resolution: fixed
Status: assignedclosed

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.

comment:4 Changed 14 years ago by Jim Ursetto

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.

Note: See TracTickets for help on using tickets.