mirror of https://github.com/hykilpikonna/AquaDX
[O] Aimedb: ignore invalid requests
parent
a48f2b1f17
commit
eb30451cfa
|
@ -25,8 +25,7 @@ class AimeDbDecoder : ByteToMessageDecoder() {
|
||||||
override fun decode(ctx: ChannelHandlerContext, input: ByteBuf, out: MutableList<Any>) {
|
override fun decode(ctx: ChannelHandlerContext, input: ByteBuf, out: MutableList<Any>) {
|
||||||
if (input.readableBytes() < 16) return
|
if (input.readableBytes() < 16) return
|
||||||
if (length == 0) length = getLength(input)
|
if (length == 0) length = getLength(input)
|
||||||
|
if (length < 0 || input.readableBytes() < length) return
|
||||||
if (input.readableBytes() < length) return
|
|
||||||
|
|
||||||
// Create a byte array to store the encrypted data
|
// Create a byte array to store the encrypted data
|
||||||
val result = AimeDbEncryption.decrypt(input.readBytes(length))
|
val result = AimeDbEncryption.decrypt(input.readBytes(length))
|
||||||
|
@ -46,7 +45,7 @@ class AimeDbDecoder : ByteToMessageDecoder() {
|
||||||
* @param input the request
|
* @param input the request
|
||||||
* @return int the length of this request
|
* @return int the length of this request
|
||||||
*/
|
*/
|
||||||
private fun getLength(input: ByteBuf): Int {
|
private fun getLength(input: ByteBuf): Int = try {
|
||||||
val currentPos = input.readerIndex()
|
val currentPos = input.readerIndex()
|
||||||
val result = AimeDbEncryption.decrypt(input)
|
val result = AimeDbEncryption.decrypt(input)
|
||||||
|
|
||||||
|
@ -55,6 +54,10 @@ class AimeDbDecoder : ByteToMessageDecoder() {
|
||||||
assert(header == 0x3e) { "AimeDB: Invalid header $header" }
|
assert(header == 0x3e) { "AimeDB: Invalid header $header" }
|
||||||
|
|
||||||
// Read the length from offset 6
|
// Read the length from offset 6
|
||||||
return result.getShortLE(currentPos + 6).toInt()
|
result.getShortLE(currentPos + 6).toInt()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
logger.info("AimeDB: Invalid request received")
|
||||||
|
logger.debug("AimeDB: Invalid request received: ${input.toString(Charsets.UTF_8)}")
|
||||||
|
-1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue