DefaultSocks5CommandRequest incorrectly rejects SOCKS5 commands with dstPort=0
Motivation: According to SOCKS 5 spec, dstPort = 0 is a valid value in case of UDP ASSOCIATE. Modifications: - Allow 0 as port. - Add unit tests. Result: Fixes [#7156].
This commit is contained in:
parent
d9d0e633dc
commit
f5bea11ee4
@ -59,8 +59,8 @@ public final class DefaultSocks5CommandRequest extends AbstractSocks5Message imp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dstPort <= 0 || dstPort >= 65536) {
|
if (dstPort < 0 || dstPort > 65535) {
|
||||||
throw new IllegalArgumentException("dstPort: " + dstPort + " (expected: 1~65535)");
|
throw new IllegalArgumentException("dstPort: " + dstPort + " (expected: 0~65535)");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -76,7 +76,7 @@ public class DefaultSocks5CommandRequestTest {
|
|||||||
public void testValidPortRange() {
|
public void testValidPortRange() {
|
||||||
try {
|
try {
|
||||||
new DefaultSocks5CommandRequest(Socks5CommandType.BIND, Socks5AddressType.DOMAIN,
|
new DefaultSocks5CommandRequest(Socks5CommandType.BIND, Socks5AddressType.DOMAIN,
|
||||||
"παράδειγμα.δοκιμήπαράδει", 0);
|
"παράδειγμα.δοκιμήπαράδει", -1);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
assertTrue(e instanceof IllegalArgumentException);
|
assertTrue(e instanceof IllegalArgumentException);
|
||||||
}
|
}
|
||||||
@ -87,5 +87,10 @@ public class DefaultSocks5CommandRequestTest {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
assertTrue(e instanceof IllegalArgumentException);
|
assertTrue(e instanceof IllegalArgumentException);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new DefaultSocks5CommandRequest(Socks5CommandType.BIND, Socks5AddressType.DOMAIN,
|
||||||
|
"παράδειγμα.δοκιμήπαράδει", 0);
|
||||||
|
new DefaultSocks5CommandRequest(Socks5CommandType.BIND, Socks5AddressType.DOMAIN,
|
||||||
|
"παράδειγμα.δοκιμήπαράδει", 65535);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user