aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-05-08 11:13:34 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-05-08 11:13:34 +1200
commit7ed27b733d442cb442a8049263fab282b39e5872 (patch)
tree3015a779d32e89fd591068392c0ef019635a49a9
parentde56187c1a48b3c4388ff986bd318d4683f2a344 (diff)
downloadtraccar-server-7ed27b733d442cb442a8049263fab282b39e5872.tar.gz
traccar-server-7ed27b733d442cb442a8049263fab282b39e5872.tar.bz2
traccar-server-7ed27b733d442cb442a8049263fab282b39e5872.zip
Handle GT06 empty string message (fix #1930)
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java7
-rw-r--r--test/org/traccar/protocol/Gt06ProtocolDecoderTest.java3
2 files changed, 7 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index 18524fcfa..6dc382a04 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -214,9 +214,10 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
int commandLength = buf.readUnsignedByte();
- buf.readUnsignedByte(); // server flag (reserved)
-
- position.set("command", buf.readBytes(commandLength - 1).toString(StandardCharsets.US_ASCII));
+ if (commandLength > 0) {
+ buf.readUnsignedByte(); // server flag (reserved)
+ position.set("command", buf.readBytes(commandLength - 1).toString(StandardCharsets.US_ASCII));
+ }
buf.readUnsignedShort(); // language
diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
index 3bcd2ec3a..46ee223ad 100644
--- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
@@ -16,6 +16,9 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest {
verifyNothing(decoder, binary(
"78780D01086471700328358100093F040D0A"));
+ verifyNotNull(decoder, binary(
+ "787866150000000000416c726561647920696e20746865207374617465206f66206675656c20737570706c7920746f20726573756d652c74686520636f6d6d616e64206973206e6f742072756e6e696e672100000000000000000000000000000000000001001981e50d0a"));
+
verifyAttributes(decoder, binary(
"78782d152500000000437574206f666620746865206675656c20737570706c793a2053756363657373210002013b898a0d0a"));