From 0516da098c915ec1e3128b63004ca1b38c7f3f92 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Jun 2015 18:06:32 +0900 Subject: [PATCH] Fix for pull request #115, added null check for IPAddress parameter in the WebSocketServer (System.Net.IPAddress, int, bool) constructor --- websocket-sharp/Ext.cs | 5 +---- websocket-sharp/Server/WebSocketServer.cs | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 77db7fb7..5f3689de 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1193,13 +1193,10 @@ namespace WebSocketSharp /// /// A to test. /// - /// - /// is . - /// public static bool IsLocal (this System.Net.IPAddress address) { if (address == null) - throw new ArgumentNullException ("address"); + return false; if (address.Equals (System.Net.IPAddress.Any) || System.Net.IPAddress.IsLoopback (address)) return true; diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 3c2b18d9..99ff33c1 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -34,6 +34,7 @@ * - Juan Manuel Lallana * - Jonas Hovgaard * - Liryna + * - Rohan Singh */ #endregion @@ -225,8 +226,8 @@ namespace WebSocketSharp.Server /// , , and . /// /// - /// An instance initialized by this constructor listens for the incoming connection requests - /// on . + /// An instance initialized by this constructor listens for the incoming connection requests on + /// . /// /// /// A that represents the local IP address of the server. @@ -238,6 +239,9 @@ namespace WebSocketSharp.Server /// A that indicates providing a secure connection or not. /// (true indicates providing a secure connection.) /// + /// + /// is . + /// /// /// /// isn't a local IP address. @@ -249,19 +253,20 @@ namespace WebSocketSharp.Server /// Pair of and is invalid. /// /// - /// - /// is . - /// /// - /// isn't between 1 and 65535. + /// isn't between 1 and 65535 inclusive. /// public WebSocketServer (System.Net.IPAddress address, int port, bool secure) { + if (address == null) + throw new ArgumentNullException ("address"); + if (!address.IsLocal ()) throw new ArgumentException ("Not a local IP address: " + address, "address"); if (!port.IsPortNumber ()) - throw new ArgumentOutOfRangeException ("port", "Not between 1 and 65535: " + port); + throw new ArgumentOutOfRangeException ( + "port", "Not between 1 and 65535 inclusive: " + port); if ((port == 80 && secure) || (port == 443 && !secure)) throw new ArgumentException (