Fix IndexOutOfBoundsException issues.
This commit is contained in:
parent
b0bb4057f6
commit
b8179ca1c0
@ -237,6 +237,7 @@ public class EncryptedPacket implements IStreamedPacket, IInternalCache {
|
||||
public void loadPayload(byte[] packetData) throws PacketException {
|
||||
if (packetData == null) throw new NullPointerException("packetData is null");
|
||||
synchronized (slock) {
|
||||
try {
|
||||
int index = 1;
|
||||
|
||||
int cipherLenCache = (packetData[index++] & 0xff) * 16777216;
|
||||
@ -246,7 +247,8 @@ public class EncryptedPacket implements IStreamedPacket, IInternalCache {
|
||||
if (cipherLenCache < 1) throw new PacketException("cipher length less than 1");
|
||||
|
||||
byte[] cipherSettingsCache = new byte[cipherLenCache];
|
||||
System.arraycopy(packetData, index, cipherSettingsCache, 0, cipherLenCache); index += cipherLenCache;
|
||||
System.arraycopy(packetData, index, cipherSettingsCache, 0, cipherLenCache);
|
||||
index += cipherLenCache;
|
||||
try {
|
||||
cipherFactory.setSettings(cipherSettingsCache);
|
||||
} catch (CipherException e) {
|
||||
@ -285,6 +287,9 @@ public class EncryptedPacket implements IStreamedPacket, IInternalCache {
|
||||
} finally {
|
||||
if (!useCache) encryptedCache = null;
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
throw new PacketException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,6 +139,7 @@ public class NetworkEncryptionCipherPacket implements IStreamedPacket, IAcknowle
|
||||
if (packetData == null) throw new NullPointerException("packetData is null");
|
||||
if (packetData.length < 5) throw new PacketException("no data");
|
||||
synchronized (slock) {
|
||||
try {
|
||||
acknowledgement = (packetData[0] == 1);
|
||||
if (!acknowledgement && packetData[0] != 0) acknowledgement = null;
|
||||
int index = 1;
|
||||
@ -166,6 +167,9 @@ public class NetworkEncryptionCipherPacket implements IStreamedPacket, IAcknowle
|
||||
ciphers[i] = "";
|
||||
}
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
throw new PacketException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,6 +106,7 @@ public class NetworkEncryptionUpgradePacket implements IPacket, IAcknowledgement
|
||||
if (packetData == null) throw new NullPointerException("packetData is null");
|
||||
if (packetData.length < 2) throw new PacketException("no data");
|
||||
synchronized (slock) {
|
||||
try {
|
||||
acknowledgement = (packetData[0] == 1);
|
||||
if (!acknowledgement && packetData[0] != 0) acknowledgement = null;
|
||||
|
||||
@ -121,6 +122,9 @@ public class NetworkEncryptionUpgradePacket implements IPacket, IAcknowledgement
|
||||
throw new PacketException(e);
|
||||
}
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
throw new PacketException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user