From 80d22b8df573e399f5834d6ce5bdcdd727ea0f9b Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Mon, 24 Jan 2022 22:12:35 +0100 Subject: jinterface: Fix encoding bugs for pids, ports and refs in OtpOutputStream for functions write_pid/4, write_port/3 and write_ref/3. --- .../com/ericsson/otp/erlang/OtpOutputStream.java | 31 +++++++++------------- 1 file changed, 12 insertions(+), 19 deletions(-) (limited to 'lib/jinterface/java_src') diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java index 917e5baf3a..bf76fda490 100644 --- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java +++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java @@ -700,24 +700,22 @@ public class OtpOutputStream extends ByteArrayOutputStream { * the nodename. * * @param id - * an arbitrary number. Only the low order 15 bits will be used. + * an arbitrary number. * * @param serial - * another arbitrary number. Only the low order 13 bits will be - * used. + * another arbitrary number. * * @param creation - * yet another arbitrary number. Only the low order 2 bits will - * be used. + * node incarnation number. * */ public void write_pid(final String node, final int id, final int serial, final int creation) { write1(OtpExternal.newPidTag); write_atom(node); - write4BE(id & 0x7fff); // 15 bits - write4BE(serial & 0x1fff); // 13 bits - write1(creation & 0x3); // 2 bits + write4BE(id); + write4BE(serial); + write4BE(creation); } /** @@ -751,8 +749,8 @@ public class OtpOutputStream extends ByteArrayOutputStream { public void write_port(final String node, final int id, final int creation) { write1(OtpExternal.newPortTag); write_atom(node); - write4BE(id & 0xfffffff); // 28 bits - write1(creation & 0x3); // 2 bits + write4BE(id); + write4BE(creation); } /** @@ -797,12 +795,11 @@ public class OtpOutputStream extends ByteArrayOutputStream { * the nodename. * * @param ids - * an array of arbitrary numbers. Only the low order 18 bits of - * the first number will be used. At most three numbers + * an array of arbitrary numbers. At most three numbers * will be read from the array. * * @param creation - * another arbitrary number. Only the low order 2 bits will be used. + * another arbitrary number. * */ public void write_ref(final String node, final int[] ids, final int creation) { @@ -818,13 +815,9 @@ public class OtpOutputStream extends ByteArrayOutputStream { write_atom(node); - write1(creation & 0x3); // 2 bits + write4BE(creation); - // first int gets truncated to 18 bits - write4BE(ids[0] & 0x3ffff); - - // remaining ones are left as is - for (int i = 1; i < arity; i++) { + for (int i = 0; i < arity; i++) { write4BE(ids[i]); } } -- cgit v1.2.1