Skip to content

Commit 81d77c2

Browse files
committed
NuGet v1.0.4.2, fix for SICK-2021-060
1 parent b697b9c commit 81d77c2

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

IpMatcher/IpMatcher.csproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,25 @@
33
<PropertyGroup>
44
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net452;net5.0</TargetFrameworks>
55
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
6-
<Version>1.0.4.1</Version>
6+
<Version>1.0.4.2</Version>
77
<Authors>Joel Christner</Authors>
88
<Description>Library for maintaining a match list of IP addresses and networks and comparing inputs to see if a match exists.</Description>
99
<Copyright>(c)2021 Joel Christner</Copyright>
1010
<PackageProjectUrl>https://github.com/jchristn/ipmatcher</PackageProjectUrl>
1111
<RepositoryUrl>https://github.com/jchristn/ipmatcher</RepositoryUrl>
1212
<RepositoryType>Github</RepositoryType>
1313
<PackageLicenseUrl></PackageLicenseUrl>
14-
<PackageReleaseNotes>XML documentation</PackageReleaseNotes>
14+
<PackageReleaseNotes>Fix for SICK-2021-060</PackageReleaseNotes>
1515
<PackageTags>ip address match netmask network mask subnet cidr</PackageTags>
1616
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
1717
</PropertyGroup>
1818

1919
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.0|AnyCPU'">
20-
<DocumentationFile>C:\Code\Misc\IpMatcher\IpMatcher\IpMatcher.xml</DocumentationFile>
20+
<DocumentationFile>IpMatcher.xml</DocumentationFile>
21+
</PropertyGroup>
22+
23+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.0|AnyCPU'">
24+
<DocumentationFile>IpMatcher.xml</DocumentationFile>
2125
</PropertyGroup>
2226

2327
<ItemGroup>

IpMatcher/IpMatcher.xml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

IpMatcher/Matcher.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public void Add(string ip, string netmask)
5959
if (String.IsNullOrEmpty(ip)) throw new ArgumentNullException(nameof(ip));
6060
if (String.IsNullOrEmpty(netmask)) throw new ArgumentNullException(nameof(netmask));
6161

62+
ip = IPAddress.Parse(ip).ToString();
63+
netmask = IPAddress.Parse(netmask).ToString();
64+
6265
string baseAddress = GetBaseIpAddress(ip, netmask);
6366
IPAddress parsed = IPAddress.Parse(baseAddress);
6467
if (Exists(baseAddress, netmask)) return;
@@ -83,6 +86,9 @@ public bool Exists(string ip, string netmask)
8386
if (String.IsNullOrEmpty(ip)) throw new ArgumentNullException(nameof(ip));
8487
if (String.IsNullOrEmpty(netmask)) throw new ArgumentNullException(nameof(netmask));
8588

89+
ip = IPAddress.Parse(ip).ToString();
90+
netmask = IPAddress.Parse(netmask).ToString();
91+
8692
lock (_CacheLock)
8793
{
8894
if (_Cache.ContainsKey(ip))
@@ -116,6 +122,8 @@ public void Remove(string ip)
116122
{
117123
if (String.IsNullOrEmpty(ip)) throw new ArgumentNullException(nameof(ip));
118124

125+
ip = IPAddress.Parse(ip).ToString();
126+
119127
lock (_CacheLock)
120128
{
121129
_Cache = _Cache.Where(d => !d.Key.Equals(ip)).ToDictionary(d => d.Key, d => d.Value);
@@ -140,6 +148,8 @@ public bool MatchExists(string ip)
140148
{
141149
if (String.IsNullOrEmpty(ip)) throw new ArgumentNullException(nameof(ip));
142150

151+
ip = IPAddress.Parse(ip).ToString();
152+
143153
IPAddress parsed = IPAddress.Parse(ip);
144154

145155
lock (_CacheLock)

0 commit comments

Comments
 (0)