Fix regression introduced by 20e32f62ec

Motivation:

Because of a regression sometimes accept could produce an IllegalArgumentException

Modifications:

Correctly respect offset when decode port and scope id.

Result:

No more IllegalArgumentException
This commit is contained in:
Norman Maurer 2015-02-24 10:59:49 +01:00
parent dc8c7fc14a
commit 25bf720ca0

View File

@ -473,7 +473,7 @@ final class Native {
static InetSocketAddress address(byte[] addr, int offset, int len) {
// The last 4 bytes are always the port
final int port = decodeInt(addr, len - 4);
final int port = decodeInt(addr, offset + len - 4);
final InetAddress address;
try {
@ -494,7 +494,7 @@ final class Native {
case 24:
byte[] ipv6 = new byte[16];
System.arraycopy(addr, offset, ipv6, 0, 16);
int scopeId = decodeInt(addr, len - 8);
int scopeId = decodeInt(addr, offset + len - 8);
address = Inet6Address.getByAddress(null, ipv6, scopeId);
break;
default: