From: Mathieu Desnoyers Date: Wed, 22 Apr 2020 18:14:36 +0000 (-0400) Subject: Java agent: Use inequality for read bound check X-Git-Tag: v2.13.0-rc1~508 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=0b7be275cc204aecb1f21884e33d7a1e4fa9023b;p=lttng-ust.git Java agent: Use inequality for read bound check Don't continue looping if bytesLeft becomes negative for unforeseen reasons. 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 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) {