aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-06-12 21:57:27 -0700
committerAnton Tananaev <anton@traccar.org>2023-06-12 21:57:36 -0700
commitf1de2533c3527aefc6f9eb15277128bb8d8ec3cb (patch)
treeaa29043e90aedf983da885aec28502f110d786f0 /src/main/java/org
parent532c414196d94661e31c48332ff4f598c27ebbcf (diff)
downloadtrackermap-server-f1de2533c3527aefc6f9eb15277128bb8d8ec3cb.tar.gz
trackermap-server-f1de2533c3527aefc6f9eb15277128bb8d8ec3cb.tar.bz2
trackermap-server-f1de2533c3527aefc6f9eb15277128bb8d8ec3cb.zip
Improve Watch frame decoder
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/protocol/WatchFrameDecoder.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/WatchFrameDecoder.java b/src/main/java/org/traccar/protocol/WatchFrameDecoder.java
index f99bd52e2..ec67aa34d 100644
--- a/src/main/java/org/traccar/protocol/WatchFrameDecoder.java
+++ b/src/main/java/org/traccar/protocol/WatchFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2023 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,14 @@ public class WatchFrameDecoder extends BaseFrameDecoder {
protected Object decode(
ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
- int endIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ']') + 1;
+ int endIndex = -1;
+ for (int i = buf.writerIndex() - 1; i >= buf.readerIndex(); i--) {
+ if (buf.getByte(i) == ']') {
+ endIndex = i + 1;
+ break;
+ }
+ }
+
if (endIndex > 0) {
ByteBuf frame = Unpooled.buffer();
while (buf.readerIndex() < endIndex) {