Skip to content

TryParse scoped ipv6 addressess for addresses enclosed in [ ] #4644

@clauderobi

Description

@clauderobi

The code does not properly decode valid IPv6LL address like [fe80::1592:96a0:88bf:d2d7%brv301]

The impacted code is in IPv6AddressImpl.cpp at line 676.

To Reproduce
Simply try to use the address above

Expected behavior
Parsing using IPv6AddressImpl::parse should work,.

  • POCO Version: 1.12.5

Additional context
This block starts at line 673 for version 1.12.5:
{
std::string::size_type start = ('[' == addr[0]) ? 1 : 0;
std::string unscopedAddr(addr, start, pos - start);
std::string scope(addr, pos + 1, addr.size() - start - pos);
Poco::UInt32 scopeId(0);
if (!(scopeId = if_nametoindex(scope.c_str())))
return IPv6AddressImpl();
if (inet_pton(AF_INET6, unscopedAddr.c_str(), &ia) == 1)
return IPv6AddressImpl(&ia, scopeId);
else
return IPv6AddressImpl();
}

Line 676 is faulty. It creates a std::string scope that includes the ending ']'.

At line 674, the opening '[' was properly detected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions