From 0b7be275cc204aecb1f21884e33d7a1e4fa9023b Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 22 Apr 2020 14:14:36 -0400 Subject: [PATCH] Java agent: Use inequality for read bound check Don't continue looping if bytesLeft becomes negative for unforeseen reasons. Signed-off-by: Mathieu Desnoyers --- .../org/lttng/ust/agent/client/LttngTcpSessiondClient.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 0f979a4f..d42bc9af 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 @@ -367,7 +367,7 @@ public class LttngTcpSessiondClient implements Runnable { int bytesLeft = data.length; int bytesOffset = 0; - while (bytesLeft != 0) { + while (bytesLeft >= 0) { int bytesRead = this.inFromSessiond.read(data, bytesOffset, bytesLeft); if (bytesRead < 0) { @@ -396,7 +396,7 @@ public class LttngTcpSessiondClient implements Runnable { return null; } - while (bytesLeft != 0) { + while (bytesLeft >= 0) { int bytesRead = inFromSessiond.read(payload, bytesOffset, bytesLeft); if (bytesRead < 0) { -- 2.34.1