Skip to content

Commit

Permalink
tls_wolfssl: amend patch with Fix RNG with writedup
Browse files Browse the repository at this point in the history
Amend patch with wolfSSL/wolfssl#6843

(cherry picked from commit e393d4c)
  • Loading branch information
razvancrainea committed Oct 6, 2023
1 parent 25cc934 commit b1654b0
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions modules/tls_wolfssl/lib/patches/wolfssl-internal-memleak-fix.patch
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,34 @@ index 930769152..46e26a313 100644
FreeSuites(ssl);
FreeHandshakeHashes(ssl);
diff --git a/src/ssl.c b/src/ssl.c
index 8d946f07b..01a4c7a54 100644
index 8d946f07b..a0f4a5fc5 100644
--- a/src/ssl.c
+++ b/src/ssl.c
@@ -747,6 +747,13 @@ static int DupSSL(WOLFSSL* dup, WOLFSSL* ssl)
@@ -731,6 +731,8 @@ void FreeWriteDup(WOLFSSL* ssl)
*/
static int DupSSL(WOLFSSL* dup, WOLFSSL* ssl)
{
+ word16 tmp_weOwnRng;
+
/* shared dupWrite setup */
ssl->dupWrite = (WriteDup*)XMALLOC(sizeof(WriteDup), ssl->heap,
DYNAMIC_TYPE_WRITEDUP);
@@ -747,6 +749,8 @@ static int DupSSL(WOLFSSL* dup, WOLFSSL* ssl)
ssl->dupWrite->dupCount = 2; /* both sides have a count to start */
dup->dupWrite = ssl->dupWrite; /* each side uses */

+ if (dup->options.weOwnRng) {
+ wc_FreeRng(dup->rng);
+ XFREE(dup->rng, dup->heap, DYNAMIC_TYPE_RNG);
+ dup->rng = NULL;
+ dup->options.weOwnRng = 0;
+ }
+ tmp_weOwnRng = dup->options.weOwnRng;
+
/* copy write parts over to dup writer */
XMEMCPY(&dup->specs, &ssl->specs, sizeof(CipherSpecs));
XMEMCPY(&dup->options, &ssl->options, sizeof(Options));
--
2.42.0

@@ -769,6 +773,9 @@ static int DupSSL(WOLFSSL* dup, WOLFSSL* ssl)
dup->truncated_hmac = ssl->truncated_hmac;
#endif

+ /* Restore rng option */
+ dup->options.weOwnRng = tmp_weOwnRng;
+
/* unique side dup setup */
dup->dupSide = WRITE_DUP_SIDE;
ssl->dupSide = READ_DUP_SIDE;

0 comments on commit b1654b0

Please sign in to comment.