diff options
-rw-r--r-- | lib/vtls/schannel.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c index 92b6da3d3..7b406c557 100644 --- a/lib/vtls/schannel.c +++ b/lib/vtls/schannel.c @@ -823,7 +823,7 @@ schannel_recv(struct connectdata *conn, int sockindex, char *buf, size_t len, CURLcode *err) { size_t size = 0; - ssize_t nread = 0, ret = 0; + ssize_t nread = 0; CURLcode result; struct SessionHandle *data = conn->data; struct ssl_connect_data *connssl = &conn->ssl[sockindex]; @@ -989,10 +989,16 @@ schannel_recv(struct connectdata *conn, int sockindex, infof(data, "schannel: encrypted data cached: offset %zu length %zu\n", connssl->encdata_offset, connssl->encdata_length); } - else{ + else { /* reset encrypted buffer offset, because there is no data remaining */ connssl->encdata_offset = 0; } + } /* check if something went wrong and we need to return an error */ + else { + infof(data, "schannel: failed to read data from server: %s\n", + Curl_sspi_strerror(conn, sspi_status)); + *err = CURLE_RECV_ERROR; + return -1; } /* check if server wants to renegotiate the connection context */ @@ -1021,7 +1027,6 @@ schannel_recv(struct connectdata *conn, int sockindex, size = len < connssl->decdata_offset ? len : connssl->decdata_offset; if(size > 0) { memcpy(buf, connssl->decdata_buffer, size); - ret = size; /* move remaining decrypted data forward to the beginning of buffer */ memmove(connssl->decdata_buffer, connssl->decdata_buffer + size, @@ -1031,27 +1036,16 @@ schannel_recv(struct connectdata *conn, int sockindex, infof(data, "schannel: decrypted data returned %zd\n", size); infof(data, "schannel: decrypted data buffer: offset %zu length %zu\n", connssl->decdata_offset, connssl->decdata_length); - } - - /* check if the server closed the connection */ - if(ret <= 0 && ( /* special check for Windows 2000 Professional */ - sspi_status == SEC_I_CONTEXT_EXPIRED || - (sspi_status == SEC_E_OK && connssl->encdata_offset > 0 && - connssl->encdata_buffer[0] == 0x15))) { + } /* check if the server closed the connection */ + else if(sspi_status == SEC_I_CONTEXT_EXPIRED || + /* special check for Windows 2000 Professional */ + (sspi_status == SEC_E_OK && connssl->encdata_offset > 0 && + connssl->encdata_buffer[0] == 0x15)) { infof(data, "schannel: server closed the conunection\n"); *err = CURLE_OK; - return 0; } - /* check if something went wrong and we need to return an error */ - if(ret < 0 && sspi_status != SEC_E_OK) { - infof(data, "schannel: failed to read data from server: %s\n", - Curl_sspi_strerror(conn, sspi_status)); - *err = CURLE_RECV_ERROR; - return -1; - } - - return ret; + return size; } CURLcode |