diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-04-29 22:11:47 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-04-29 22:11:47 -0700 |
commit | 35b902cd59070a7185d99640851b99798a0d1eb7 (patch) | |
tree | 8eb5719c424f7c58235940d20af67e56397087da /src/main | |
parent | 707389659d7d1e08f774bf82557f0bcff4b13e37 (diff) | |
download | trackermap-server-35b902cd59070a7185d99640851b99798a0d1eb7.tar.gz trackermap-server-35b902cd59070a7185d99640851b99798a0d1eb7.tar.bz2 trackermap-server-35b902cd59070a7185d99640851b99798a0d1eb7.zip |
Fix buffer reference issues
Diffstat (limited to 'src/main')
6 files changed, 9 insertions, 9 deletions
diff --git a/src/main/java/org/traccar/protocol/AutoTrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/AutoTrackProtocolDecoder.java index 3c1fd256b..da7f6b5a6 100644 --- a/src/main/java/org/traccar/protocol/AutoTrackProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/AutoTrackProtocolDecoder.java @@ -103,7 +103,7 @@ public class AutoTrackProtocolDecoder extends BaseProtocolDecoder { switch (type) { case MSG_LOGIN_REQUEST: - String imei = ByteBufUtil.hexDump(buf.readBytes(8)); + String imei = ByteBufUtil.hexDump(buf.readSlice(8)); DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei); if (deviceSession == null) { return null; diff --git a/src/main/java/org/traccar/protocol/FifotrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/FifotrackProtocolDecoder.java index a9cf025af..2e728a918 100644 --- a/src/main/java/org/traccar/protocol/FifotrackProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/FifotrackProtocolDecoder.java @@ -196,7 +196,7 @@ public class FifotrackProtocolDecoder extends BaseProtocolDecoder { parser.nextInt(); // offset parser.nextInt(); // size buf.readerIndex(dataIndex); - photo.writeBytes(buf.readBytes(buf.readableBytes() - 3)); // ignore checksum + buf.readBytes(photo, buf.readableBytes() - 3); // ignore checksum if (photo.isWritable()) { requestPhoto(channel, remoteAddress, imei, photoId); } else { diff --git a/src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java index 256848990..68ebe39a2 100644 --- a/src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java @@ -84,7 +84,7 @@ public class Minifinder2ProtocolDecoder extends BaseProtocolDecoder { switch (key) { case 0x01: DeviceSession deviceSession = getDeviceSession( - channel, remoteAddress, buf.readBytes(15).toString(StandardCharsets.US_ASCII)); + channel, remoteAddress, buf.readCharSequence(15, StandardCharsets.US_ASCII).toString()); if (deviceSession == null) { return null; } diff --git a/src/main/java/org/traccar/protocol/RetranslatorProtocolDecoder.java b/src/main/java/org/traccar/protocol/RetranslatorProtocolDecoder.java index 0688c9b0e..5bf6cef50 100644 --- a/src/main/java/org/traccar/protocol/RetranslatorProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/RetranslatorProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 - 2019 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. @@ -47,7 +47,7 @@ public class RetranslatorProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedInt(); // length int idLength = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0x00) - buf.readerIndex(); - String id = buf.readBytes(idLength).toString(StandardCharsets.US_ASCII); + String id = buf.readCharSequence(idLength, StandardCharsets.US_ASCII).toString(); buf.readByte(); DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, id); if (deviceSession == null) { @@ -68,7 +68,7 @@ public class RetranslatorProtocolDecoder extends BaseProtocolDecoder { int dataType = buf.readUnsignedByte(); int nameLength = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0x00) - buf.readerIndex(); - String name = buf.readBytes(nameLength).toString(StandardCharsets.US_ASCII); + String name = buf.readCharSequence(nameLength, StandardCharsets.US_ASCII).toString(); buf.readByte(); if (name.equals("posinfo")) { @@ -83,7 +83,7 @@ public class RetranslatorProtocolDecoder extends BaseProtocolDecoder { switch (dataType) { case 1: int len = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0x00) - buf.readerIndex(); - position.set(name, buf.readBytes(len).toString(StandardCharsets.US_ASCII)); + position.set(name, buf.readCharSequence(len, StandardCharsets.US_ASCII).toString()); buf.readByte(); break; case 3: diff --git a/src/main/java/org/traccar/protocol/TekFrameDecoder.java b/src/main/java/org/traccar/protocol/TekFrameDecoder.java index 44d2c590e..c56e1f8f2 100644 --- a/src/main/java/org/traccar/protocol/TekFrameDecoder.java +++ b/src/main/java/org/traccar/protocol/TekFrameDecoder.java @@ -33,7 +33,7 @@ public class TekFrameDecoder extends BaseFrameDecoder { int length = 17 + buf.getUnsignedByte(16) + (BitUtil.from(buf.getUnsignedByte(15), 6) << 6); if (buf.readableBytes() >= length) { - return buf.readBytes(length); + return buf.readRetainedSlice(length); } return null; diff --git a/src/main/java/org/traccar/protocol/TekProtocolDecoder.java b/src/main/java/org/traccar/protocol/TekProtocolDecoder.java index a9101e65f..33ff51d2d 100644 --- a/src/main/java/org/traccar/protocol/TekProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TekProtocolDecoder.java @@ -69,7 +69,7 @@ public class TekProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // rssi buf.readUnsignedByte(); // battery / status - String imei = ByteBufUtil.hexDump(buf.readBytes(8)).substring(1); + String imei = ByteBufUtil.hexDump(buf.readSlice(8)).substring(1); DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei); if (deviceSession == null) { return null; |