Fix for pull request #115, added null check for IPAddress parameter in the WebSocketServer (System.Net.IPAddress, int, bool) constructor
This commit is contained in:
parent
5e3814fa71
commit
0516da098c
@ -1193,13 +1193,10 @@ namespace WebSocketSharp
|
|||||||
/// <param name="address">
|
/// <param name="address">
|
||||||
/// A <see cref="System.Net.IPAddress"/> to test.
|
/// A <see cref="System.Net.IPAddress"/> to test.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <exception cref="ArgumentNullException">
|
|
||||||
/// <paramref name="address"/> is <see langword="null"/>.
|
|
||||||
/// </exception>
|
|
||||||
public static bool IsLocal (this System.Net.IPAddress address)
|
public static bool IsLocal (this System.Net.IPAddress address)
|
||||||
{
|
{
|
||||||
if (address == null)
|
if (address == null)
|
||||||
throw new ArgumentNullException ("address");
|
return false;
|
||||||
|
|
||||||
if (address.Equals (System.Net.IPAddress.Any) || System.Net.IPAddress.IsLoopback (address))
|
if (address.Equals (System.Net.IPAddress.Any) || System.Net.IPAddress.IsLoopback (address))
|
||||||
return true;
|
return true;
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
* - Juan Manuel Lallana <juan.manuel.lallana@gmail.com>
|
* - Juan Manuel Lallana <juan.manuel.lallana@gmail.com>
|
||||||
* - Jonas Hovgaard <j@jhovgaard.dk>
|
* - Jonas Hovgaard <j@jhovgaard.dk>
|
||||||
* - Liryna <liryna.stark@gmail.com>
|
* - Liryna <liryna.stark@gmail.com>
|
||||||
|
* - Rohan Singh <rohan-singh@hotmail.com>
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -225,8 +226,8 @@ namespace WebSocketSharp.Server
|
|||||||
/// <paramref name="address"/>, <paramref name="port"/>, and <paramref name="secure"/>.
|
/// <paramref name="address"/>, <paramref name="port"/>, and <paramref name="secure"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// An instance initialized by this constructor listens for the incoming connection requests
|
/// An instance initialized by this constructor listens for the incoming connection requests on
|
||||||
/// on <paramref name="port"/>.
|
/// <paramref name="port"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="address">
|
/// <param name="address">
|
||||||
/// A <see cref="System.Net.IPAddress"/> that represents the local IP address of the server.
|
/// A <see cref="System.Net.IPAddress"/> that represents the local IP address of the server.
|
||||||
@ -238,6 +239,9 @@ namespace WebSocketSharp.Server
|
|||||||
/// A <see cref="bool"/> that indicates providing a secure connection or not.
|
/// A <see cref="bool"/> that indicates providing a secure connection or not.
|
||||||
/// (<c>true</c> indicates providing a secure connection.)
|
/// (<c>true</c> indicates providing a secure connection.)
|
||||||
/// </param>
|
/// </param>
|
||||||
|
/// <exception cref="ArgumentNullException">
|
||||||
|
/// <paramref name="address"/> is <see langword="null"/>.
|
||||||
|
/// </exception>
|
||||||
/// <exception cref="ArgumentException">
|
/// <exception cref="ArgumentException">
|
||||||
/// <para>
|
/// <para>
|
||||||
/// <paramref name="address"/> isn't a local IP address.
|
/// <paramref name="address"/> isn't a local IP address.
|
||||||
@ -249,19 +253,20 @@ namespace WebSocketSharp.Server
|
|||||||
/// Pair of <paramref name="port"/> and <paramref name="secure"/> is invalid.
|
/// Pair of <paramref name="port"/> and <paramref name="secure"/> is invalid.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </exception>
|
/// </exception>
|
||||||
/// <exception cref="ArgumentNullException">
|
|
||||||
/// <paramref name="address"/> is <see langword="null"/>.
|
|
||||||
/// </exception>
|
|
||||||
/// <exception cref="ArgumentOutOfRangeException">
|
/// <exception cref="ArgumentOutOfRangeException">
|
||||||
/// <paramref name="port"/> isn't between 1 and 65535.
|
/// <paramref name="port"/> isn't between 1 and 65535 inclusive.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public WebSocketServer (System.Net.IPAddress address, int port, bool secure)
|
public WebSocketServer (System.Net.IPAddress address, int port, bool secure)
|
||||||
{
|
{
|
||||||
|
if (address == null)
|
||||||
|
throw new ArgumentNullException ("address");
|
||||||
|
|
||||||
if (!address.IsLocal ())
|
if (!address.IsLocal ())
|
||||||
throw new ArgumentException ("Not a local IP address: " + address, "address");
|
throw new ArgumentException ("Not a local IP address: " + address, "address");
|
||||||
|
|
||||||
if (!port.IsPortNumber ())
|
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))
|
if ((port == 80 && secure) || (port == 443 && !secure))
|
||||||
throw new ArgumentException (
|
throw new ArgumentException (
|
||||||
|
Loading…
Reference in New Issue
Block a user