From 085741cacf5c89d0ef696b979bfae48aef5703c8 Mon Sep 17 00:00:00 2001 From: Hein Tibosch Date: Wed, 13 Sep 2023 15:29:38 +0800 Subject: [PATCH] FreeRTOS_FillEndPoint: save pxNext before clearing entire endpoint struct --- source/FreeRTOS_Routing.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/FreeRTOS_Routing.c b/source/FreeRTOS_Routing.c index 527e49c7a..d7ab7a326 100644 --- a/source/FreeRTOS_Routing.c +++ b/source/FreeRTOS_Routing.c @@ -109,7 +109,12 @@ struct xIPv6_Couple /* Fill in and add an end-point to a network interface. * The user must make sure that the object pointed to by 'pxEndPoint' * will remain to exist. */ + + /* As the endpoint might be part of a linked list, + protect the field pxNext from being overwritten. */ + NetworkEndPoint_t * pxNext = pxEndPoint->pxNext; ( void ) memset( pxEndPoint, 0, sizeof( *pxEndPoint ) ); + pxEndPoint->pxNext = pxNext; ulIPAddress = FreeRTOS_inet_addr_quick( ucIPAddress[ 0 ], ucIPAddress[ 1 ], ucIPAddress[ 2 ], ucIPAddress[ 3 ] ); pxEndPoint->ipv4_settings.ulNetMask = FreeRTOS_inet_addr_quick( ucNetMask[ 0 ], ucNetMask[ 1 ], ucNetMask[ 2 ], ucNetMask[ 3 ] );