Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
schannel_recv: return the correct code
Bug: http://curl.haxx.se/bug/view.cgi?id=1462
Reported-by: Tae Hyoung Ahn
  • Loading branch information
bagder committed Dec 9, 2014
1 parent 680d5fd commit 145c263
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/vtls/curl_schannel.c
Expand Up @@ -1013,6 +1013,8 @@ schannel_recv(struct connectdata *conn, int sockindex,
infof(data, "schannel: decrypted data buffer: offset %zu length %zu\n",
connssl->decdata_offset, connssl->decdata_length);
}
else
ret = 0;

/* check if the server closed the connection */
if(ret <= 0 && ( /* special check for Windows 2000 Professional */
Expand Down

4 comments on commit 145c263

@chris-araman
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the behavior of curl_easy_recv when there is no data to receive on the socket. Before this change, curl_easy_recv would return CURLE_AGAIN. Now it returns CURLE_OK with 0 bytes received, as if the socket has been closed.

@bagder
Copy link
Member Author

@bagder bagder commented on 145c263 Jan 19, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Do you have a suggested fix too?

@mback2k
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that it would have returned CURLE_AGAIN before. That only happens on SEC_E_INCOMPLETE_MESSAGE. But I guess a solution could be to add *err = CURLE_AGAIN;right after the new ret = 0; within the same condition. I will test it this week.

@chris-araman
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, I was talking about the resultant change in behavior to curl_easy_recv. This change also causes schannel_recv to return 0 with *err == CURLE_AGAIN. The return of 0 (and not -1, as before) in turn causes curl_easy_recv to return CURLE_OK instead of the expected CURLE_AGAIN.

My proposed fix:

  else if (*err == CURLE_OK)
    ret = 0;

Please sign in to comment.