adjust read ahead, some sanity checks and rebase

This commit is contained in:
Jacob Barthelmeh
2016-12-09 13:16:17 -07:00
parent 724e50c4fd
commit 091fc10147
4 changed files with 10 additions and 49 deletions

View File

@ -1292,7 +1292,9 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
if (wolfSSL_CTX_get_read_ahead(ctx) != 0) {
err_sys("bad read ahead default value");
}
/* wolfSSL_CTX_set_read_ahead(ctx, 1); use not recommended */
if (wolfSSL_CTX_set_read_ahead(ctx, 1) != SSL_SUCCESS) {
err_sys("error setting read ahead value");
}
#endif
ssl = wolfSSL_new(ctx);

View File

@ -9384,15 +9384,6 @@ static int GetInputData(WOLFSSL *ssl, word32 size)
return MEMORY_E;
}
#ifdef OPENSSL_EXTRA
/* if read ahead then try to read the full buffer size */
if (ssl->readAhead != 0 && ssl->options.usingNonblock) {
if (maxLength > inSz) {
inSz = maxLength;
}
}
#endif /* OPENSSL_EXTRA */
/* Put buffer data at start if not there */
if (usedLength > 0 && ssl->buffers.inputBuffer.idx != 0)
XMEMMOVE(ssl->buffers.inputBuffer.buffer,
@ -9504,7 +9495,7 @@ int ProcessReply(WOLFSSL* ssl)
int ret = 0, type, readSz;
int atomicUser = 0;
word32 startIdx = 0;
#if defined(WOLFSSL_DTLS) || defined(OPENSSL_EXTRA)
#if defined(WOLFSSL_DTLS)
int used;
#endif
@ -9535,18 +9526,6 @@ int ProcessReply(WOLFSSL* ssl)
/* get header or return error */
if (!ssl->options.dtls) {
#ifdef OPENSSL_EXTRA
(void)used;
if (ssl->readAhead != 0 && ssl->options.usingNonblock) {
/* read ahead may already have header */
used = ssl->buffers.inputBuffer.length -
ssl->buffers.inputBuffer.idx;
if (used < readSz)
if ((ret = GetInputData(ssl, readSz)) < 0)
return ret;
}
else
#endif /* OPENSSL_EXTRA */
if ((ret = GetInputData(ssl, readSz)) < 0)
return ret;
} else {
@ -9603,17 +9582,6 @@ int ProcessReply(WOLFSSL* ssl)
/* get sz bytes or return error */
if (!ssl->options.dtls) {
#ifdef OPENSSL_EXTRA
if (ssl->readAhead != 0 && ssl->options.usingNonblock) {
/* read ahead may already have */
used = ssl->buffers.inputBuffer.length -
ssl->buffers.inputBuffer.idx;
if (used < ssl->curSize)
if ((ret = GetInputData(ssl, ssl->curSize)) < 0)
return ret;
}
else
#endif /* OPENSSL_EXTRA */
if ((ret = GetInputData(ssl, ssl->curSize)) < 0)
return ret;
} else {
@ -9675,17 +9643,6 @@ int ProcessReply(WOLFSSL* ssl)
/* get sz bytes or return error */
if (!ssl->options.dtls) {
#ifdef OPENSSL_EXTRA
if (ssl->readAhead != 0 && ssl->options.usingNonblock) {
/* read ahead may already have header */
used = ssl->buffers.inputBuffer.length -
ssl->buffers.inputBuffer.idx;
if (used < ssl->curSize)
if ((ret = GetInputData(ssl, ssl->curSize)) < 0)
return ret;
}
else
#endif /* OPENSSL_EXTRA */
if ((ret = GetInputData(ssl, ssl->curSize)) < 0)
return ret;
} else {

View File

@ -2991,6 +2991,8 @@ static void test_wolfSSL_BIO(void)
AssertIntEQ(BIO_write(f_bio2, cert, sizeof(cert)), sizeof(cert));
AssertIntEQ((int)BIO_get_fp(f_bio2, &f2), SSL_SUCCESS);
AssertIntEQ(BIO_reset(f_bio2), 0);
AssertIntEQ(BIO_seek(f_bio2, 4), 0);
BIO_free(f_bio1);
BIO_free(f_bio2);

View File

@ -78,7 +78,7 @@ WOLFSSL_API void wolfSSL_EVP_CIPHER_CTX_free(WOLFSSL_EVP_CIPHER_CTX *ctx)
WOLFSSL_API int wolfSSL_EVP_EncryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
unsigned char *out, int *outl)
{
if (ctx->enc){
if (ctx && ctx->enc){
WOLFSSL_ENTER("wolfSSL_EVP_EncryptFinal");
return wolfSSL_EVP_CipherFinal(ctx, out, outl);
}
@ -89,7 +89,7 @@ WOLFSSL_API int wolfSSL_EVP_EncryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
WOLFSSL_API int wolfSSL_EVP_EncryptFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
unsigned char *out, int *outl)
{
if (ctx->enc){
if (ctx && ctx->enc){
WOLFSSL_ENTER("wolfSSL_EVP_EncryptFinal_ex");
return wolfSSL_EVP_CipherFinal(ctx, out, outl);
}
@ -100,7 +100,7 @@ WOLFSSL_API int wolfSSL_EVP_EncryptFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
WOLFSSL_API int wolfSSL_EVP_DecryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
unsigned char *out, int *outl)
{
if (ctx->enc)
if (ctx && ctx->enc)
return 0;
else{
WOLFSSL_ENTER("wolfSSL_EVP_DecryptFinal");
@ -111,7 +111,7 @@ WOLFSSL_API int wolfSSL_EVP_DecryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
WOLFSSL_API int wolfSSL_EVP_DecryptFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
unsigned char *out, int *outl)
{
if (ctx->enc)
if (ctx && ctx->enc)
return 0;
else{
WOLFSSL_ENTER("wolfSSL_EVP_CipherFinal_ex");