Skip to content

SocketAddress.cpp ipv6_from_address does not clear byte who have been moved. FIX included #2931

@EduardPon

Description

@EduardPon

In the function ipv6_from_address(), address values of IPv6 address after a :: is found are moved to the end of the short[] array. But the source memory of the moved part should also be cleared with zeros before the address values in front of the :: are copied. In the current implementation this may lead to an invalid address conversion.

// Move suffix to end
memmove(&shorts[NSAPI_IPv6_BYTES/2-suffix], &shorts[0], suffix*sizeof(uint16_t));

// FIX, clear source of moved memory. 
for( int i = 0 ; i < NSAPI_IPv6_BYTES/2-suffix; i++ )
{
    shorts[i] = 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions