Merge pull request #1732 from kojo1/Ticket-4169-2

Ticket 4169: eliminate ssl->CBIORecv/Send overwritten in SSL_set_bio
pull/1740/head
JacobBarthelmeh 2018-08-02 14:58:25 -06:00 committed by GitHub
commit 782ea74fbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 3 deletions

View File

@ -1382,6 +1382,7 @@ int InitSSL_Ctx(WOLFSSL_CTX* ctx, WOLFSSL_METHOD* method, void* heap)
#endif
#ifdef OPENSSL_EXTRA
ctx->verifyDepth = MAX_CHAIN_DEPTH;
ctx->cbioFlag = WOLFSSL_CBIO_NONE;
#endif
#ifndef WOLFSSL_USER_IO
@ -4645,6 +4646,7 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup)
/* copy over application session context ID */
ssl->sessionCtxSz = ctx->sessionCtxSz;
XMEMCPY(ssl->sessionCtx, ctx->sessionCtx, ctx->sessionCtxSz);
ssl->cbioFlag = ctx->cbioFlag;
#endif
InitCiphers(ssl);

View File

@ -11116,10 +11116,12 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
ssl->biowr = wr;
/* set SSL to use BIO callbacks instead */
if (rd != NULL && rd->type != WOLFSSL_BIO_SOCKET) {
if (((ssl->cbioFlag & WOLFSSL_CBIO_RECV) == 0) &&
(rd != NULL && rd->type != WOLFSSL_BIO_SOCKET)) {
ssl->CBIORecv = BioReceive;
}
if (wr != NULL && wr->type != WOLFSSL_BIO_SOCKET) {
if (((ssl->cbioFlag & WOLFSSL_CBIO_SEND) == 0) &&
(wr != NULL && wr->type != WOLFSSL_BIO_SOCKET)) {
ssl->CBIOSend = BioSend;
}
}

View File

@ -1433,12 +1433,18 @@ int EmbedCrlLookup(WOLFSSL_CRL* crl, const char* url, int urlSz)
WOLFSSL_API void wolfSSL_CTX_SetIORecv(WOLFSSL_CTX *ctx, CallbackIORecv CBIORecv)
{
ctx->CBIORecv = CBIORecv;
#ifdef OPENSSL_EXTRA
ctx->cbioFlag |= WOLFSSL_CBIO_RECV;
#endif
}
WOLFSSL_API void wolfSSL_CTX_SetIOSend(WOLFSSL_CTX *ctx, CallbackIOSend CBIOSend)
{
ctx->CBIOSend = CBIOSend;
#ifdef OPENSSL_EXTRA
ctx->cbioFlag |= WOLFSSL_CBIO_SEND;
#endif
}

View File

@ -2414,6 +2414,14 @@ enum KeyUpdateRequest {
#endif /* WOLFSSL_TLS13 */
#ifdef OPENSSL_EXTRA
enum SetCBIO {
WOLFSSL_CBIO_NONE = 0,
WOLFSSL_CBIO_RECV = 0x1,
WOLFSSL_CBIO_SEND = 0x2,
};
#endif
/* wolfSSL context type */
struct WOLFSSL_CTX {
WOLFSSL_METHOD* method;
@ -2507,6 +2515,7 @@ struct WOLFSSL_CTX {
const unsigned char *alpn_cli_protos;/* ALPN client protocol list */
unsigned int alpn_cli_protos_len;
byte sessionCtxSz;
byte cbioFlag; /* WOLFSSL_CBIO_RECV/SEND: CBIORecv/Send is set */
CallbackInfoState* CBIS; /* used to get info about SSL state */
#endif
CallbackIORecv CBIORecv;
@ -2652,7 +2661,6 @@ struct WOLFSSL_CTX {
#endif
};
WOLFSSL_LOCAL
WOLFSSL_CTX* wolfSSL_CTX_new_ex(WOLFSSL_METHOD* method, void* heap);
WOLFSSL_LOCAL
@ -3542,6 +3550,9 @@ struct WOLFSSL {
WriteDup* dupWrite; /* valid pointer indicates ON */
/* side that decrements dupCount to zero frees overall structure */
byte dupSide; /* write side or read side */
#endif
#ifdef OPENSSL_EXTRA
byte cbioFlag; /* WOLFSSL_CBIO_RECV/SEND: CBIORecv/Send is set */
#endif
CallbackIORecv CBIORecv;
CallbackIOSend CBIOSend;