InetEndpoint: disallow huge ports

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2018-12-15 22:05:43 +01:00
parent 053ca232aa
commit fe424197da

View File

@ -51,7 +51,7 @@ public final class InetEndpoint {
} catch (final URISyntaxException e) { } catch (final URISyntaxException e) {
throw new IllegalArgumentException(e); throw new IllegalArgumentException(e);
} }
if (uri.getPort() < 0) if (uri.getPort() < 0 || uri.getPort() > 65535)
throw new ParseException(InetEndpoint.class, endpoint, "Missing/invalid port number"); throw new ParseException(InetEndpoint.class, endpoint, "Missing/invalid port number");
try { try {
InetAddresses.parse(uri.getHost()); InetAddresses.parse(uri.getHost());