diff --git a/src/tls_schannel.c b/src/tls_schannel.c index 6633be7..82545ef 100644 --- a/src/tls_schannel.c +++ b/src/tls_schannel.c @@ -102,7 +102,7 @@ tls_t *tls_new(xmpp_ctx_t *ctx, sock_t sock) return NULL; } - if (!(pInitSecurityInterface = + if (!(pInitSecurityInterface = (void *)GetProcAddress(tls->hsec32, "InitSecurityInterfaceA"))) { tls_free(tls); return NULL; @@ -196,7 +196,7 @@ void tls_free(tls_t *tls) FreeLibrary(tls->hsec32); tls->hsec32 = NULL; } - + xmpp_free(tls->ctx, tls); return; } @@ -360,7 +360,7 @@ int tls_start(tls_t *tls) return 0; } - tls->sft->QueryContextAttributes(&(tls->hctxt), SECPKG_ATTR_STREAM_SIZES, + tls->sft->QueryContextAttributes(&(tls->hctxt), SECPKG_ATTR_STREAM_SIZES, &(tls->spcss)); tls->recvbuffermaxlen = tls->spcss.cbHeader + tls->spcss.cbMaximumMessage @@ -401,7 +401,7 @@ int tls_is_recoverable(int error) int tls_pending(tls_t *tls) { // There are 3 cases: // - there is data in ready buffer, so it is by default pending - // - there is data in recv buffer. If it is not decrypted yet, means it + // - there is data in recv buffer. If it is not decrypted yet, means it // was incomplete. This should be processed again only if there is data // on the physical connection // - there is data on the physical connection. This case is treated @@ -440,7 +440,7 @@ int tls_read(tls_t *tls, void * const buff, const size_t len) read = tls_read(tls, newbuff, len - bytes); if (read == -1) { - if (tls_is_recoverable(tls->lasterror)) { + if (tls_is_recoverable(tls->lasterror)) { return bytes; } @@ -454,11 +454,11 @@ int tls_read(tls_t *tls, void * const buff, const size_t len) /* next, top up our recv buffer */ bytes = sock_read(tls->sock, tls->recvbuffer + tls->recvbufferpos, tls->recvbuffermaxlen - tls->recvbufferpos); - + if (bytes == 0) { tls->lasterror = WSAECONNRESET; return -1; - } + } if (bytes == -1) { if (!tls_is_recoverable(sock_error())) { @@ -499,7 +499,7 @@ int tls_read(tls_t *tls, void * const buff, const size_t len) ret = tls->sft->DecryptMessage(&(tls->hctxt), &sbddec, 0, NULL); if (ret == SEC_E_OK) { - memcpy(tls->readybuffer, sbdec[1].pvBuffer, sbdec[1].cbBuffer); + memcpy(tls->readybuffer, sbdec[1].pvBuffer, sbdec[1].cbBuffer); tls->readybufferpos = 0; tls->readybufferlen = sbdec[1].cbBuffer; /* have we got some data left over? If so, copy it to the start @@ -631,8 +631,8 @@ int tls_write(tls_t *tls, const void * const buff, const size_t len) if (ret == -1 && !tls_is_recoverable(tls_error(tls))) { return -1; - } - + } + if (remain > tls->spcss.cbMaximumMessage) { sent += tls->spcss.cbMaximumMessage; remain -= tls->spcss.cbMaximumMessage;