aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/Gt06FrameDecoder.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/org/traccar/protocol/Gt06FrameDecoder.java b/src/org/traccar/protocol/Gt06FrameDecoder.java
index 9b93979e4..c8b5e56ae 100644
--- a/src/org/traccar/protocol/Gt06FrameDecoder.java
+++ b/src/org/traccar/protocol/Gt06FrameDecoder.java
@@ -38,17 +38,18 @@ public class Gt06FrameDecoder extends FrameDecoder {
length += 2 + buf.getUnsignedShort(buf.readerIndex() + 2);
}
- if (buf.readableBytes() >= length) {
- if (buf.getUnsignedShort(buf.readerIndex() + length - 2) == 0x0d0a) {
- return buf.readBytes(length);
- } else {
- int endIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0x0d);
- if (endIndex > 0 && buf.writerIndex() > endIndex + 1 && buf.getByte(endIndex + 1) == 0x0a) {
- return buf.readBytes(endIndex + 2 - buf.readerIndex());
- }
- }
+ if (buf.readableBytes() >= length && buf.getUnsignedShort(buf.readerIndex() + length - 2) == 0x0d0a) {
+ return buf.readBytes(length);
}
+ int endIndex = buf.readerIndex() - 1;
+ do {
+ endIndex = buf.indexOf(endIndex + 1, buf.writerIndex(), (byte) 0x0d);
+ if (endIndex > 0 && buf.writerIndex() > endIndex + 1 && buf.getByte(endIndex + 1) == 0x0a) {
+ return buf.readBytes(endIndex + 2 - buf.readerIndex());
+ }
+ } while (endIndex > 0);
+
return null;
}