wolfSSL / wolfssl

The wolfSSL library is a small, fast, portable implementation of TLS/SSL for embedded devices to the cloud. wolfSSL supports up to TLS 1.3 and DTLS 1.3!
https://www.wolfssl.com
GNU General Public License v2.0
2.36k stars 834 forks source link

ifdef out all code in isDGramSock() when WOLFSSL_NO_SOCK defined. #8197

Closed anhu closed 1 day ago

anhu commented 3 days ago

In that case, simply return false.

Fixes ZD18962

JacobBarthelmeh commented 1 day ago

The relevant user_settings.h defines are:

WOLFSSL_DTLS
WOLFSSL_NO_SOCK
USE_WOLFSSL_IO

If allowing WOLFSSL_NO_SOCK and USE_WOLFSSL_IO at the same time then we need to have isDGramSock return correctly.

Previous versions (back to v5.4.0) we did the following in EmbedSendTo and did not have a isDGramSock internal API:

    if (getsockopt(sd, SOL_SOCKET, SO_TYPE, &type, &length) == 0 &&             
            type != SOCK_DGRAM) {                                               
        /* Probably a TCP socket. peer and peerSz MUST be NULL and 0 */         
    }  

I think a more complete fix is either we make an assumption on the type for XSOCKOPT_TYPE_OPTVAL_TYPE when not already defined. Or if the user is setting up custom socket calls with they define it.

With either fix though we should add a user_settings.h config file to our CI testing that builds this use case if supporting it going forward.

anhu commented 1 day ago

Closing. This will be handled by another engineer.