aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java5
-rw-r--r--src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java3
2 files changed, 7 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
index 80e84c156..98f74ac84 100644
--- a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -1229,7 +1229,10 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // external device type code
int length = buf.readableBytes() - 9; // line break + checksum + index + checksum + footer
- if (length < 8) {
+
+ if (length <= 0) {
+ return null;
+ } else if (length < 8) {
position.set(
Position.PREFIX_TEMP + 1,
Double.parseDouble(buf.readCharSequence(length - 1, StandardCharsets.US_ASCII).toString()));
diff --git a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java
index e6b7b7ce3..d63dc2d9a 100644
--- a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java
@@ -17,6 +17,9 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, binary(
"78780D01086471700328358100093F040D0A"));
+ verifyNull(decoder, binary(
+ "797900099b0380d600046f91e90d0a"));
+
verifyAttribute(decoder, binary(
"7979000E9B0332382E33A1E60D0A0289BE490D0A"),
Position.PREFIX_TEMP + 1, 28.3);