Skip to content

Potential typo/bug in _nxd_ipv6_address_set regarding finding an available IPv6 address structure? #355

@Hareesh-S-T

Description

@Hareesh-S-T

Was going through the source code for NetXDuo and came across the following block of code in nxd_ipv6_address_set.c, around line 130 that seemed suspicious to me (unless I have grossly misunderstood the code)

   /* Find an avaiable IPv6 address structure. */
    for (i = 0; i < NX_MAX_IPV6_ADDRESSES; i++)
    {
        /* Look for invalid entries. */
        if (!ip_ptr -> nx_ipv6_address[i].nxd_ipv6_address_valid)
        {

            /* An available entry is found. */
            index = i;
            break;
        }
    }

    if (index == (UINT)0xFFFFFFFF)
    {
        tx_mutex_put(&(ip_ptr -> nx_ip_protection));
        return(NX_NO_MORE_ENTRIES);
    }

From my understanding of this snippet, the latter if condition would never catch a NX_NO_MORE_ENTRIES case unless NX_MAX_IPV6_ADDRESSES was set to 0xFFFFFFFF and would result in an out of bounds access of
ip_ptr -> nx_ipv6_address[index]
at line 155 if NX_LOOPBACK_IPV6_ENABLED is not defined.

Is this a point of concern?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Discussion

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions