updates to shutdown and mymktemp

This commit is contained in:
lchristina26
2015-02-11 09:37:54 -07:00
parent b26b5f1b51
commit 4c7b076cea
3 changed files with 15 additions and 15 deletions

View File

@@ -6351,9 +6351,7 @@ static int DoAlert(WOLFSSL* ssl, byte* input, word32* inOutIdx, int* type,
WOLFSSL_MSG(" close notify"); WOLFSSL_MSG(" close notify");
ssl->options.closeNotify = 1; ssl->options.closeNotify = 1;
} }
if (!ssl->options.sentNotify) { WOLFSSL_ERROR(*type);
WOLFSSL_ERROR(*type);
}
if (ssl->keys.encryptionOn) { if (ssl->keys.encryptionOn) {
if (*inOutIdx + ssl->keys.padSz > totalSz) if (*inOutIdx + ssl->keys.padSz > totalSz)
return BUFFER_E; return BUFFER_E;
@@ -7751,9 +7749,7 @@ startScr:
while (ssl->buffers.clearOutputBuffer.length == 0) { while (ssl->buffers.clearOutputBuffer.length == 0) {
if ( (ssl->error = ProcessReply(ssl)) < 0) { if ( (ssl->error = ProcessReply(ssl)) < 0) {
if (!ssl->options.sentNotify) { WOLFSSL_ERROR(ssl->error);
WOLFSSL_ERROR(ssl->error);
}
if (ssl->error == ZERO_RETURN) { if (ssl->error == ZERO_RETURN) {
WOLFSSL_MSG("Zero return, no more data coming"); WOLFSSL_MSG("Zero return, no more data coming");
return 0; /* no more data coming */ return 0; /* no more data coming */

View File

@@ -917,6 +917,7 @@ int wolfSSL_recv(WOLFSSL* ssl, void* data, int sz, int flags)
/* SSL_SUCCESS on ok */ /* SSL_SUCCESS on ok */
int wolfSSL_shutdown(WOLFSSL* ssl) int wolfSSL_shutdown(WOLFSSL* ssl)
{ {
byte tmp;
WOLFSSL_ENTER("SSL_shutdown()"); WOLFSSL_ENTER("SSL_shutdown()");
if (ssl == NULL) if (ssl == NULL)
@@ -937,23 +938,26 @@ int wolfSSL_shutdown(WOLFSSL* ssl)
} }
ssl->options.sentNotify = 1; /* don't send close_notify twice */ ssl->options.sentNotify = 1; /* don't send close_notify twice */
WOLFSSL_LEAVE("SSL_shutdown()", ssl->error); WOLFSSL_LEAVE("SSL_shutdown()", ssl->error);
return 0;
if (ssl->options.closeNotify)
return 1;
else
return 0;
} }
/* call wolfSSL_shutdown again for bidirectional shudown */ /* call wolfSSL_shutdown again for bidirectional shudown */
if (ssl->options.sentNotify && !ssl->options.closeNotify) { if (ssl->options.sentNotify && !ssl->options.closeNotify) {
ssl->error = ReceiveData(ssl, 0, 0, 0); ssl->error = wolfSSL_read(ssl, &tmp, 0);
if (ssl->error < 0) { if (ssl->error < 0) {
WOLFSSL_ERROR(ssl->error); WOLFSSL_ERROR(ssl->error);
return SSL_FATAL_ERROR; return SSL_FATAL_ERROR;
} }
WOLFSSL_LEAVE("SSL_shutdown()", ssl->error);
ssl->error = SSL_ERROR_SYSCALL; /* simulate OpenSSL behavior */
if(ssl->options.closeNotify)
return SSL_SUCCESS;
} }
return SSL_FATAL_ERROR;
WOLFSSL_LEAVE("SSL_shutdown()", ssl->error);
ssl->error = SSL_ERROR_SYSCALL; /* simulate OpenSSL behavior */
return SSL_SUCCESS;
} }

View File

@@ -1800,7 +1800,7 @@ static INLINE const char* mymktemp(char *tempfn, int len, int num)
static const char alphanum[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" static const char alphanum[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"; "abcdefghijklmnopqrstuvwxyz";
RNG rng; RNG rng;
int out; byte out;
if (tempfn == NULL || len < 1 || num < 1 || len <= num) { if (tempfn == NULL || len < 1 || num < 1 || len <= num) {
printf("Bad input\n"); printf("Bad input\n");