Java agent: Use inequality for read bound check
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 22 Apr 2020 18:14:36 +0000 (14:14 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 22 Apr 2020 18:15:20 +0000 (14:15 -0400)
Don't continue looping if bytesLeft becomes negative for unforeseen
reasons.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/LttngTcpSessiondClient.java

index 0f979a4f88da7d7fa97da19c6786f0dcc9fe1e90..d42bc9af4ee112c105ee48605b58c1c98843ba09 100644 (file)
@@ -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) {
This page took 0.025993 seconds and 4 git commands to generate.