From 3ba856a5f45c467b280ee37ff8d4f144f67eb819 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Wed, 30 Apr 2014 10:40:00 +0200 Subject: [PATCH] Correctly handle SocksCmdResponse. Related to #2428 Motivation: Ports range check is not correct Modification: Allow port between 0 and 65535. 0 is wildcard / unknown port here Result: Correct validation --- .../java/io/netty/handler/codec/socks/SocksCmdResponse.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdResponse.java b/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdResponse.java index b38db62121..c918c3182a 100644 --- a/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdResponse.java +++ b/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdResponse.java @@ -90,8 +90,8 @@ public final class SocksCmdResponse extends SocksResponse { } host = IDN.toASCII(host); } - if (port <= 0 && port >= 65536) { - throw new IllegalArgumentException(port + " is not in bounds 0 < x < 65536"); + if (port < 0 || port > 65535) { + throw new IllegalArgumentException(port + " is not in bounds 0 <= x <= 65535"); } this.cmdStatus = cmdStatus; this.addressType = addressType;