Skip to content

Commit

Permalink
Correctly handle incomplete message and ask curl to re-read
Browse files Browse the repository at this point in the history
  • Loading branch information
mback2k committed May 13, 2012
1 parent 723a553 commit 6eece06
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/curl_schannel.c
Expand Up @@ -740,6 +740,13 @@ schannel_recv(struct connectdata *conn, int sockindex,
&inbuf_desc, 0, NULL); &inbuf_desc, 0, NULL);
infof(data, "schannel: DecryptMessage %d\n", sspi_status); infof(data, "schannel: DecryptMessage %d\n", sspi_status);


/* check if we need more data */
if(sspi_status == SEC_E_INCOMPLETE_MESSAGE) {
infof(data, "schannel: failed to decrypt data, need more data\n");
*err = CURLE_AGAIN;
return -1;
}

/* check if everything went fine (server may want to renegotiate context) */ /* check if everything went fine (server may want to renegotiate context) */
if(sspi_status == SEC_E_OK || sspi_status == SEC_I_RENEGOTIATE || if(sspi_status == SEC_E_OK || sspi_status == SEC_I_RENEGOTIATE ||
sspi_status == SEC_I_CONTEXT_EXPIRED) { sspi_status == SEC_I_CONTEXT_EXPIRED) {
Expand Down Expand Up @@ -836,11 +843,9 @@ schannel_recv(struct connectdata *conn, int sockindex,
} }


/* check if something went wrong and we need to return an error */ /* check if something went wrong and we need to return an error */
if(ret < 0) { if(ret < 0 && sspi_status != SEC_E_OK) {
if(sspi_status == SEC_E_INCOMPLETE_MESSAGE) infof(data, "schannel: failed to read data from server\n");
*err = CURLE_AGAIN; *err = CURLE_RECV_ERROR;
else if(sspi_status != SEC_E_OK)
*err = CURLE_RECV_ERROR;
return -1; return -1;
} }


Expand Down

0 comments on commit 6eece06

Please sign in to comment.