Fix CreateAccountCodec padding

The padding must be between 1 and 8 bytes inclusive, not 0 and 7.

Signed-off-by: Graham <gpe@openrs2.org>
master
Graham 2 years ago
parent 76e7e93f3c
commit 2abd1d7ea0
  1. 11
      protocol/src/main/kotlin/org/openrs2/protocol/login/upstream/CreateAccountCodec.kt

@ -59,8 +59,12 @@ public class CreateAccountCodec @Inject constructor(
val email = input.readString() val email = input.readString()
// padding val padding = input.readableBytes()
input.skipBytes(minOf(input.readableBytes(), XTEA_BLOCK_SIZE - 1)) require(padding in 1..XTEA_BLOCK_SIZE) {
"Padding ($padding bytes) must be between 1 and $XTEA_BLOCK_SIZE bytes"
}
input.skipBytes(padding)
return LoginRequest.CreateAccount( return LoginRequest.CreateAccount(
build, build,
@ -121,7 +125,8 @@ public class CreateAccountCodec @Inject constructor(
output.writeString(input.email) output.writeString(input.email)
while ((output.writerIndex() - xteaIndex) % XTEA_BLOCK_SIZE != 0) { val padding = XTEA_BLOCK_SIZE - (output.writerIndex() - xteaIndex) % XTEA_BLOCK_SIZE
for (i in 0 until padding) {
output.writeByte(secureRandom.nextInt()) output.writeByte(secureRandom.nextInt())
} }

Loading…
Cancel
Save