Skip to content

Commit

Permalink
Fix for SSL_set_mtu -> wolfSSL_set_mtu_compat return code. Update com…
Browse files Browse the repository at this point in the history
…ment for `wolfSSL_is_init_finished` indicating it works for TLS and DTLS.
  • Loading branch information
dgarske committed Jan 3, 2025
1 parent 239b85c commit d6440be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2124,14 +2124,17 @@ int wolfSSL_dtls_set_mtu(WOLFSSL* ssl, word16 newMtu)
return WOLFSSL_SUCCESS;
}

#if defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA)
int wolfSSL_set_mtu_compat(WOLFSSL* ssl, unsigned short mtu) {
if (wolfSSL_dtls_set_mtu(ssl, mtu) == 0)
#ifdef OPENSSL_EXTRA
/* Maps to compatibility API SSL_set_mtu and is same as wolfSSL_dtls_set_mtu,
* but expects only success or failure returns. */
int wolfSSL_set_mtu_compat(WOLFSSL* ssl, unsigned short mtu)
{
if (wolfSSL_dtls_set_mtu(ssl, mtu) == WOLFSSL_SUCCESS)
return WOLFSSL_SUCCESS;
else
return WOLFSSL_FAILURE;
}
#endif /* OPENSSL_ALL || OPENSSL_EXTRA */
#endif /* OPENSSL_EXTRA */

#endif /* WOLFSSL_DTLS && (WOLFSSL_SCTP || WOLFSSL_DTLS_MTU) */

Expand Down Expand Up @@ -12596,6 +12599,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
#endif /* OPENSSL_EXTRA || WOLFSSL_EXTRA || WOLFSSL_WPAS_SMALL */

/* return true if connection established */
/* this works for TLS and DTLS */
int wolfSSL_is_init_finished(const WOLFSSL* ssl)
{
if (ssl == NULL)
Expand Down
4 changes: 4 additions & 0 deletions tests/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -90249,6 +90249,10 @@ static int test_wolfSSL_dtls_set_mtu(void)
ExpectIntEQ(wolfSSL_CTX_dtls_set_mtu(ctx, 1488), WOLFSSL_SUCCESS);
ExpectIntEQ(wolfSSL_dtls_set_mtu(ssl, 1488), WOLFSSL_SUCCESS);

#ifdef OPENSSL_EXTRA
ExpectIntEQ(SSL_set_mtu(ssl, 1488), WOLFSSL_SUCCESS);
#endif

wolfSSL_free(ssl);
wolfSSL_CTX_free(ctx);
#endif
Expand Down

0 comments on commit d6440be

Please sign in to comment.