Skip to content

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

@devslash-sec

Description

@devslash-sec

If an IPAddress is initialized as following: Poco::Net::IPAddress ip("::")
ip.toString() returns "::0.0.0.0" whereas "::" is expected.
Using this output to create an IPAddress Poco::Net::IPAddress ip("::0.0.0.0") returns "Invalid address: ::0.0.0.0".
Even though both :: and ::0.0.0.0 are valid IPv6 addresses I would suggest to add a check in IPAddressImpl.cpp IPv6AddressImpl::toString() Line 435 if the IPv4 Address that follows :: is not in 0.0.0.0/8 or 0.0.0.0/32 to keep in and output consistent.
Like:

                 if(bytes[12] != 0){
                        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]);
                }

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions