diff --git a/src/main/java/io/netty/incubator/codec/quic/InsecureQuicTokenHandler.java b/src/main/java/io/netty/incubator/codec/quic/InsecureQuicTokenHandler.java index 4cb225d08..82afb8c36 100644 --- a/src/main/java/io/netty/incubator/codec/quic/InsecureQuicTokenHandler.java +++ b/src/main/java/io/netty/incubator/codec/quic/InsecureQuicTokenHandler.java @@ -53,15 +53,16 @@ public void writeToken(ByteBuf out, ByteBuf dcid, InetSocketAddress address) { @Override public int validateToken(ByteBuf token, InetSocketAddress address) { + final byte[] addr = address.getAddress().getAddress(); + int minLength = SERVER_NAME_BYTES.length + address.getAddress().getAddress().length; - if (token.readableBytes() <= SERVER_NAME_BYTES.length + address.getAddress().getAddress().length) { + if (token.readableBytes() <= SERVER_NAME_BYTES.length + addr.length) { return -1; } if (!SERVER_NAME_BUFFER.equals(token.slice(0, SERVER_NAME_BYTES.length))) { return -1; } - final byte[] addr = address.getAddress().getAddress(); ByteBuf addressBuffer = Unpooled.wrappedBuffer(addr); try { if (!addressBuffer.equals(token.slice(SERVER_NAME_BYTES.length, addr.length))) {