[erlang-bugs] a crypto function call crashes VM
Sverker Eriksson
sverker@REDACTED
Mon Sep 5 19:45:53 CEST 2011
SUZUKI Tetsuya wrote:
> Hi,
>
> BEAM crashes when the following message digest functions using
> contexts in crypto module receive some binary as context.
> (Environment: Erlang R14B03, Mac OS X 10.6.8 (i386, MacBook Air).
>
> * md4_update/2
> * md4_final/2
> * md5_update/2
> * md5_final/2
> * sha_update/2
> * sha_final/2
> * hmac_update/2
> * hmac_final/2
>
>
>
:
> If the functions communicate with BEAM using resource objects
> include MD5_CTX data, BEAM may not crash.
>
Yes, that would be the nice way to do it. However, changing the existing
interface to return resources instead of binaries as context would break
backward compatibility.
How about three new functions like this:
hash_init(Type) -> Context
hash_update(Context, Data) -> NewContext
hash_final(Context) -> Digest
Type = md4 | md5 | sha | hmac
Context = NewContext = opaque() [implemented as NIF resource]
Data = Digest = binary()
And then eventually deprecate the old ones.
/Sverker
More information about the erlang-bugs
mailing list