diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-02-14 02:19:31 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-02-14 02:19:31 +1300 |
commit | 5465e58749ecf553839484f4a41ca94a1621bbb8 (patch) | |
tree | 7dcff303822de95173d40c4fe55b58b58c72030f | |
parent | 621576edf95c0d3af1919113e62ac1e9245efa88 (diff) | |
download | traccar-server-5465e58749ecf553839484f4a41ca94a1621bbb8.tar.gz traccar-server-5465e58749ecf553839484f4a41ca94a1621bbb8.tar.bz2 traccar-server-5465e58749ecf553839484f4a41ca94a1621bbb8.zip |
Handle empty AT2000 message (fix #2662)
-rw-r--r-- | src/org/traccar/protocol/At2000ProtocolDecoder.java | 4 | ||||
-rw-r--r-- | test/org/traccar/protocol/At2000ProtocolDecoderTest.java | 8 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/org/traccar/protocol/At2000ProtocolDecoder.java b/src/org/traccar/protocol/At2000ProtocolDecoder.java index 00973f2aa..f990e05c2 100644 --- a/src/org/traccar/protocol/At2000ProtocolDecoder.java +++ b/src/org/traccar/protocol/At2000ProtocolDecoder.java @@ -102,6 +102,10 @@ public class At2000ProtocolDecoder extends BaseProtocolDecoder { return null; } + if (buf.capacity() <= BLOCK_LENGTH) { + return null; // empty message + } + byte[] data = new byte[buf.capacity() - BLOCK_LENGTH]; buf.readBytes(data); buf = ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, cipher.update(data)); diff --git a/test/org/traccar/protocol/At2000ProtocolDecoderTest.java b/test/org/traccar/protocol/At2000ProtocolDecoderTest.java index 596d2870d..0b1a9f471 100644 --- a/test/org/traccar/protocol/At2000ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/At2000ProtocolDecoderTest.java @@ -19,6 +19,14 @@ public class At2000ProtocolDecoderTest extends ProtocolTest { decoder = new At2000ProtocolDecoder(new At2000Protocol()); verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, + "01012f00000000000000000000000000003335373435343037313632373539388b57ec3a6ec7e3310a1ceb0a70fd751b8f2e7be6df1d6dcd80129f66fff0ea1c")); + + verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, + "89000000000000000000000000000000")); + + decoder = new At2000ProtocolDecoder(new At2000Protocol()); + + verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, "01012f0000000000000000000000000000333537343534303731363036313936ddf189075add9a32d97b54073025963e65849a3a59940d05fd8db655fc84bc6d")); verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN, |