mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-29 18:27:29 +02:00
Address code review
- Use functions instead of accessing `BIO` members - Add `wolfSSL_BIO_method_type`
This commit is contained in:
@ -134,6 +134,11 @@ static int wolfSSL_BIO_MEMORY_read(WOLFSSL_BIO* bio, void* buf, int len)
|
||||
return sz;
|
||||
}
|
||||
|
||||
int wolfSSL_BIO_method_type(const WOLFSSL_BIO *b)
|
||||
{
|
||||
return b != NULL ? b->type : (int)WOLFSSL_BIO_UNDEF;
|
||||
}
|
||||
|
||||
#ifndef WOLFCRYPT_ONLY
|
||||
/* Helper function to read from WOLFSSL_BIO_SSL type
|
||||
*
|
||||
@ -1739,8 +1744,6 @@ long wolfSSL_BIO_set_nbio(WOLFSSL_BIO* bio, long on)
|
||||
return WOLFSSL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* creates a new custom WOLFSSL_BIO_METHOD */
|
||||
WOLFSSL_BIO_METHOD *wolfSSL_BIO_meth_new(int type, const char *name)
|
||||
{
|
||||
|
@ -30759,7 +30759,8 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
||||
}
|
||||
if (ret == WOLFSSL_TICKET_RET_FATAL)
|
||||
ret = WOLFSSL_TICKET_RET_REJECT;
|
||||
if (ret < 0) return ret;
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (outLen > (int)inLen || outLen < (int)sizeof(InternalTicket)) {
|
||||
WOLFSSL_MSG("Bad user ticket decrypt len");
|
||||
return BAD_TICKET_KEY_CB_SZ;
|
||||
|
@ -170,8 +170,8 @@ int BioReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx)
|
||||
recvd = wolfSSL_BIO_read(ssl->biord, buf, sz);
|
||||
if (recvd <= 0) {
|
||||
if (/* ssl->biowr->wrIdx is checked for Bind9 */
|
||||
ssl->biowr != NULL && ssl->biowr->type == WOLFSSL_BIO_BIO &&
|
||||
ssl->biowr->wrIdx != 0 &&
|
||||
wolfSSL_BIO_method_type(ssl->biowr) == WOLFSSL_BIO_BIO &&
|
||||
wolfSSL_BIO_wpending(ssl->biowr) != 0 &&
|
||||
/* Not sure this pending check is necessary but let's double
|
||||
* check that the read BIO is empty before we signal a write
|
||||
* need */
|
||||
|
@ -764,6 +764,7 @@ wolfSSL_X509_STORE_set_verify_cb((WOLFSSL_X509_STORE *)(s), (WOLFSSL_X509_STORE_
|
||||
#define BIO_do_handshake wolfSSL_BIO_do_handshake
|
||||
#define BIO_ssl_shutdown wolfSSL_BIO_ssl_shutdown
|
||||
#define SSL_set_bio wolfSSL_set_bio
|
||||
#define BIO_method_type wolfSSL_BIO_method_type
|
||||
#define BIO_set_ssl wolfSSL_BIO_set_ssl
|
||||
#define BIO_get_ssl wolfSSL_BIO_get_ssl
|
||||
#define BIO_new_ssl_connect wolfSSL_BIO_new_ssl_connect
|
||||
|
@ -446,6 +446,7 @@ struct WOLFSSL_X509_PUBKEY {
|
||||
};
|
||||
|
||||
enum BIO_TYPE {
|
||||
WOLFSSL_BIO_UNDEF = 0,
|
||||
WOLFSSL_BIO_BUFFER = 1,
|
||||
WOLFSSL_BIO_SOCKET = 2,
|
||||
WOLFSSL_BIO_SSL = 3,
|
||||
@ -1609,6 +1610,7 @@ WOLFSSL_API long wolfSSL_BIO_set_fd(WOLFSSL_BIO* b, int fd, int flag);
|
||||
#endif
|
||||
WOLFSSL_API int wolfSSL_BIO_set_close(WOLFSSL_BIO *b, long flag);
|
||||
WOLFSSL_API void wolfSSL_set_bio(WOLFSSL* ssl, WOLFSSL_BIO* rd, WOLFSSL_BIO* wr);
|
||||
WOLFSSL_API int wolfSSL_BIO_method_type(const WOLFSSL_BIO *b);
|
||||
|
||||
#ifndef NO_FILESYSTEM
|
||||
WOLFSSL_API WOLFSSL_BIO_METHOD *wolfSSL_BIO_s_file(void);
|
||||
|
Reference in New Issue
Block a user