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

Nico Kruber <>
Thu Apr 26 10:16:40 CEST 2012


On Wednesday 25 April 2012 17:45:11 Kenneth Lundin wrote:
> Den 25 apr 2012 10:48 skrev "Nico Kruber" <>:
> > 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).
> 
> What do you mean with this? Please explain. What is broken?

in short, what currently is broken in JInterface is that erlang terms created 
by erlang:term_to_binary(Term, [compressed]) can sometimes not be read, 
expecially larger terms. A exception will be thrown that the read size does 
not match the expected size.

> > I applied a patch posted on erlang-questins in September 2009, see
> > http://erlang.org/pipermail/erlang-patches/2009-September/000478.html
> > It was not enough to fix the bug though so I extended this patch a little.
> > 
> > https://github.com/NicoK/otp/compare/jinterface.fix_compressed_binary
> 
> https://github.com/NicoK/otp/compare/jinterface.fix_compressed_binary.patch
> 
> > Regards
> > Nico Kruber
> > _______________________________________________
> > erlang-patches mailing list
> > 
> > http://erlang.org/mailman/listinfo/erlang-patches
> 
> /Kenneth, Erlang/OTP Ericsson


More information about the erlang-patches mailing list