Skip to content

Commit

Permalink
Fixed port RegExp accepting values that are too high
Browse files Browse the repository at this point in the history
  • Loading branch information
burdoto committed Oct 10, 2019
1 parent a2fbc8e commit a43a850
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions VBANDeck/SendBasicScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,18 @@ public string PortProperty
return;
}

if (Regex.IsMatch(value, "[0-9]{1,6}"))
int port;
if (Regex.IsMatch(value, "[0-9]{1,5}")
&& (port = int.Parse(value)) <= 65535)
{
Port = int.Parse(value);
}
else
{
Logger.Instance.LogMessage(TracingLevel.WARN,
"Invalid Port [" + value + "] was entered! Falling back to " +
VBAN.DefaultPort);
Port = VBAN.DefaultPort;
Port = port;
return;
}

Logger.Instance.LogMessage(TracingLevel.WARN,
"Invalid Port [" + value + "] was entered! Falling back to " +
VBAN.DefaultPort);
Port = VBAN.DefaultPort;
}
}

Expand Down

0 comments on commit a43a850

Please sign in to comment.