From 1e1110055efac3a1713fe0c7b5f36d5b98895d92 Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Thu, 19 May 2016 14:54:59 -0400 Subject: [PATCH] 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 --- .../org/lttng/ust/agent/client/LttngTcpSessiondClient.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; } -- 2.34.1