Skip to content

Commit 2df57b7

Browse files
committed
Fix from review
1 parent 6c5378c commit 2df57b7

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/tls.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15260,13 +15260,18 @@ static int TLSX_Write(TLSX* list, byte* output, byte* semaphore,
1526015260
}
1526115261
}
1526215262

15263-
if ((word32)*pOffset + (word32)offset > WOLFSSL_MAX_16BIT) {
15264-
WOLFSSL_MSG("TLSX_Write total extensions length exceeds word16");
15265-
return BUFFER_E;
15263+
/* Only validate and commit the aggregate offset when the loop
15264+
* completed without error; on the error path, leave *pOffset
15265+
* unchanged and return the original failure reason so callers
15266+
* see the real error instead of a masking BUFFER_E. */
15267+
if (ret == 0) {
15268+
if ((word32)*pOffset + (word32)offset > WOLFSSL_MAX_16BIT) {
15269+
WOLFSSL_MSG("TLSX_Write total extensions length exceeds word16");
15270+
return BUFFER_E;
15271+
}
15272+
*pOffset += offset;
1526615273
}
1526715274

15268-
*pOffset += offset;
15269-
1527015275
return ret;
1527115276
}
1527215277

0 commit comments

Comments
 (0)