From 7f86a7086a858e1755dba2e7c65d32674797b32c Mon Sep 17 00:00:00 2001 From: Joao Leitao Date: Mon, 6 Mar 2023 22:29:49 +0000 Subject: [PATCH] additional fix on the serialization of SignedProtoMessage --- .../novasys/babel/generic/signed/SignedMessageSerializer.java | 2 +- .../fct/di/novasys/babel/generic/signed/SignedProtoMessage.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/pt/unl/fct/di/novasys/babel/generic/signed/SignedMessageSerializer.java b/src/main/java/pt/unl/fct/di/novasys/babel/generic/signed/SignedMessageSerializer.java index 06273ee..2375150 100644 --- a/src/main/java/pt/unl/fct/di/novasys/babel/generic/signed/SignedMessageSerializer.java +++ b/src/main/java/pt/unl/fct/di/novasys/babel/generic/signed/SignedMessageSerializer.java @@ -15,7 +15,7 @@ public void serialize(T msg, ByteBuf out) throws IOException { ByteBuf serial = Unpooled.buffer(); serial.writeShort(msg.getId()); this.serializeBody(msg, serial); - msg.serializedMessage = ByteBufUtil.getBytes(serial); + msg.serializedMessage = ByteBufUtil.getBytes(serial.slice()); } out.writeInt(msg.serializedMessage.length); diff --git a/src/main/java/pt/unl/fct/di/novasys/babel/generic/signed/SignedProtoMessage.java b/src/main/java/pt/unl/fct/di/novasys/babel/generic/signed/SignedProtoMessage.java index 877f69f..65778c0 100644 --- a/src/main/java/pt/unl/fct/di/novasys/babel/generic/signed/SignedProtoMessage.java +++ b/src/main/java/pt/unl/fct/di/novasys/babel/generic/signed/SignedProtoMessage.java @@ -38,6 +38,7 @@ public final void signMessage(PrivateKey key) throws NoSuchAlgorithmException, I "\nVerify that the serializer exists and is returned by the method getSerializer()"); } else { ByteBuf b = Unpooled.buffer(); + b.writeShort(this.getId()); serializer.serializeBody(this, b); this.serializedMessage = ByteBufUtil.getBytes(b.slice()); }