From: Alexandre Montplaisir Date: Thu, 19 May 2016 18:54:59 +0000 (-0400) Subject: Fix: Verify number of bytes contained in sessiond agent commands X-Git-Tag: v2.8.0~7 X-Git-Url: http://git.liburcu.org/?a=commitdiff_plain;ds=sidebyside;h=6b8cdda9e4d87e9dee0b887ac733577b26be0ad3;p=lttng-ust.git Fix: Verify number of bytes contained in sessiond agent commands The command header indicates the number of bytes in the payload. Make sure those bytes were really present on the socket, and throw an error if they were not. Signed-off-by: Alexandre Montplaisir Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/LttngTcpSessiondClient.java b/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/LttngTcpSessiondClient.java index 333dd5b0..37f4ec4e 100644 --- a/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/LttngTcpSessiondClient.java +++ b/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/LttngTcpSessiondClient.java @@ -374,7 +374,10 @@ public class LttngTcpSessiondClient implements Runnable { return null; } - this.inFromSessiond.read(payload, 0, payload.length); + int read = inFromSessiond.read(payload, 0, payload.length); + if (read != payload.length) { + throw new IOException("Unexpected number of bytes read in sessiond command payload"); + } return payload; }