Network: Fix minor issues with IP address parsing and add tests

This commit is contained in:
Jérôme Leclercq
2022-02-24 12:38:08 +01:00
parent 13f2132110
commit 7dbaed9aa5
4 changed files with 170 additions and 33 deletions

View File

@@ -353,7 +353,7 @@ namespace Nz
// validation of ipv4 subspace ::ffff:x.x
if (mappedIPv4)
{
static const UInt8 abyPfx[] = {0,0, 0,0, 0,0, 0,0, 0,0, 0xFF,0xFF};
const UInt8 abyPfx[] = {0,0, 0,0, 0,0, 0,0, 0,0, 0xFF,0xFF};
if (std::memcmp(result, abyPfx, sizeof(abyPfx)) != 0)
return false;
}
@@ -376,11 +376,10 @@ namespace Nz
++addressPtr; // past the colon
unsigned int portValue;
if (!Detail::ParseDecimal(addressPtr, &portValue, nullptr) || portValue > 65535)
if (!Detail::ParseDecimal(addressPtr, &portValue, &addressPtr) || portValue > 65535)
return false;
if (port)
*port = static_cast<UInt16>(portValue);
*port = static_cast<UInt16>(portValue);
}
else // finished just with IP address
*port = 0; // indicate we have no port part