[erlang-patches] fixed reading compressed binary terms from Java

Nico Kruber <>
Wed Apr 25 10:48:04 CEST 2012

Problem was that when reading from an InputStream, you can only specify a 
maximum number of bytes to read. Java doesn't guarantee that it actually reads 
this many bytes - it could be less!

This patch now reads up until the expected size number of bytes. If there are 
more than expected, the actual number of available bytes is not printed (we 
probably shouldn't read the additional bytes, security-wise - the erlang 
external byte representation is broken in this case though).

I applied a patch posted on erlang-questins in September 2009, see
It was not enough to fix the bug though so I extended this patch a little.


Nico Kruber

More information about the erlang-patches mailing list