diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-03-27 00:49:29 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-03-27 00:49:29 +1300 |
commit | 094a9acabf8f0b94d1c62f77a409dbf7e3b137f6 (patch) | |
tree | bcae7f282c10eeca2677dca2e9acc9839a8a6759 /src/org/traccar | |
parent | d847f80334498bde6993b8f3a38c7df05d83b47b (diff) | |
download | traccar-server-094a9acabf8f0b94d1c62f77a409dbf7e3b137f6.tar.gz traccar-server-094a9acabf8f0b94d1c62f77a409dbf7e3b137f6.tar.bz2 traccar-server-094a9acabf8f0b94d1c62f77a409dbf7e3b137f6.zip |
Improve Watch frame decoding
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/protocol/WatchFrameDecoder.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/WatchFrameDecoder.java b/src/org/traccar/protocol/WatchFrameDecoder.java index 9adea2843..f6b5ef12c 100644 --- a/src/org/traccar/protocol/WatchFrameDecoder.java +++ b/src/org/traccar/protocol/WatchFrameDecoder.java @@ -37,11 +37,6 @@ public class WatchFrameDecoder extends FrameDecoder { int lengthIndex = buf.indexOf(idIndex, buf.writerIndex(), (byte) '*') + 1; if (lengthIndex <= 0) { return null; - } else if (lengthIndex - idIndex > 10 + 1) { - lengthIndex = buf.indexOf(lengthIndex, buf.writerIndex(), (byte) '*') + 1; - if (lengthIndex <= 0) { - return null; - } } int payloadIndex = buf.indexOf(lengthIndex, buf.writerIndex(), (byte) '*'); @@ -49,6 +44,15 @@ public class WatchFrameDecoder extends FrameDecoder { return null; } + if (payloadIndex + 5 < buf.writerIndex() && buf.getByte(payloadIndex + 5) == '*' + && buf.toString(payloadIndex + 1, 4, StandardCharsets.US_ASCII).matches("[0-9A-F]+")) { + lengthIndex = payloadIndex + 1; + payloadIndex = buf.indexOf(lengthIndex, buf.writerIndex(), (byte) '*'); + if (payloadIndex < 0) { + return null; + } + } + int length = Integer.parseInt( buf.toString(lengthIndex, payloadIndex - lengthIndex, StandardCharsets.US_ASCII), 16); if (buf.readableBytes() >= payloadIndex + 1 + length + 1) { |