Skip to content

Commit 75e7d5e

Browse files
committed
fix: split message > MTU on WOLFSSL_NO_DTLS_SIZE_CHECK
1 parent 988ba34 commit 75e7d5e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/internal.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25961,22 +25961,28 @@ int SendData(WOLFSSL* ssl, const void* data, size_t sz)
2596125961
if (sent == (word32)sz) break;
2596225962

2596325963
buffSz = (word32)sz - sent;
25964-
outputSz = wolfSSL_GetRecordSize(ssl, (word32)sz - sent, 1);
25965-
#if defined(WOLFSSL_DTLS) && !defined(WOLFSSL_NO_DTLS_SIZE_CHECK)
25964+
outputSz = wolfSSL_GetRecordSize(ssl, (word32)buffSz, 1);
25965+
#if defined(WOLFSSL_DTLS)
2596625966
if (ssl->options.dtls) {
2596725967
#if defined(WOLFSSL_DTLS_MTU)
2596825968
int mtu = ssl->dtlsMtuSz;
2596925969
#else
2597025970
int mtu = MAX_MTU;
2597125971
#endif
2597225972
if (outputSz > mtu) {
25973+
#if defined(WOLFSSL_NO_DTLS_SIZE_CHECK)
25974+
/* split instead of error out */
25975+
buffSz = min(buffSz, wolfSSL_GetMaxPlaintextSize(ssl));
25976+
outputSz = wolfSSL_GetRecordSize(ssl, (word32)buffSz, 1);
25977+
#else
2597325978
error = DTLS_SIZE_ERROR;
2597425979
ssl->error = error;
2597525980
WOLFSSL_ERROR(error);
2597625981
return error;
25982+
#endif /* WOLFSSL_NO_DTLS_SIZE_CHECK */
2597725983
}
2597825984
}
25979-
#endif /* WOLFSSL_DTLS && !WOLFSSL_NO_DTLS_SIZE_CHECK */
25985+
#endif /* WOLFSSL_DTLS */
2598025986

2598125987
/* check for available size, it does also DTLS MTU checks */
2598225988
if ((ret = CheckAvailableSize(ssl, outputSz)) != 0)
@@ -41869,7 +41875,6 @@ int wolfSSL_GetMaxPlaintextSize(WOLFSSL *ssl)
4186941875
#endif /* WOLFSSL_DTLS */
4187041876

4187141877
return maxFrag;
41872-
4187341878
}
4187441879
/**
4187541880
* Return the max fragment size. This is essentially the maximum

0 commit comments

Comments
 (0)