From d2c479845948d1bdbae31cb105cbd0b7c4381621 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Wed, 6 Nov 2019 08:57:33 +1000 Subject: [PATCH] Modify linked list traversal - fix for compiler bug KeyShare and PreSharedKey traverse linked list using a handle. Customer reported their compiler couldn't handle the assignment, so, using a temporary. --- src/tls.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/tls.c b/src/tls.c index fd441f171..baf401850 100644 --- a/src/tls.c +++ b/src/tls.c @@ -7540,6 +7540,7 @@ static int TLSX_KeyShare_New(KeyShareEntry** list, int group, void *heap, KeyShareEntry** keyShareEntry) { KeyShareEntry* kse; + KeyShareEntry** next; kse = (KeyShareEntry*)XMALLOC(sizeof(KeyShareEntry), heap, DYNAMIC_TYPE_TLSX); @@ -7550,8 +7551,11 @@ static int TLSX_KeyShare_New(KeyShareEntry** list, int group, void *heap, kse->group = (word16)group; /* Add it to the back and maintain the links. */ - while (*list != NULL) - list = &((*list)->next); + while (*list != NULL) { + /* Assign to temporary to work around compiler bug found by customer. */ + next = &((*list)->next); + list = next; + } *list = kse; *keyShareEntry = kse; @@ -8318,6 +8322,7 @@ static int TLSX_PreSharedKey_New(PreSharedKey** list, byte* identity, PreSharedKey** preSharedKey) { PreSharedKey* psk; + PreSharedKey** next; psk = (PreSharedKey*)XMALLOC(sizeof(PreSharedKey), heap, DYNAMIC_TYPE_TLSX); if (psk == NULL) @@ -8334,8 +8339,11 @@ static int TLSX_PreSharedKey_New(PreSharedKey** list, byte* identity, psk->identityLen = len; /* Add it to the end and maintain the links. */ - while (*list != NULL) - list = &((*list)->next); + while (*list != NULL) { + /* Assign to temporary to work around compiler bug found by customer. */ + next = &((*list)->next); + list = next; + } *list = psk; *preSharedKey = psk;