fixed GH #1570: IPv6AddressImpl::toString() returns wrong output for IPv6 address "::"

This commit is contained in:
Guenter Obiltschnig
2017-02-11 19:01:12 +01:00
parent c2aca1d109
commit a401d22a28
2 changed files with 14 additions and 7 deletions

View File

@@ -432,13 +432,16 @@ std::string IPv6AddressImpl::toString() const
else
result.append("::ffff:");
const UInt8* bytes = reinterpret_cast<const UInt8*>(&_addr);
NumberFormatter::append(result, bytes[12]);
result.append(".");
NumberFormatter::append(result, bytes[13]);
result.append(".");
NumberFormatter::append(result, bytes[14]);
result.append(".");
NumberFormatter::append(result, bytes[15]);
if (bytes[12] != 0) // only 0.0.0.0 can start with zero
{
NumberFormatter::append(result, bytes[12]);
result.append(".");
NumberFormatter::append(result, bytes[13]);
result.append(".");
NumberFormatter::append(result, bytes[14]);
result.append(".");
NumberFormatter::append(result, bytes[15]);
}
return result;
}
else