cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Curl_read() silently ignores an error during read

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 17 Mar 2010 23:45:08 +0100 (CET)

On Wed, 17 Mar 2010, Kamil Dudka wrote:

> while looking into https://bugzilla.redhat.com/565972 I discovered something
> odd in the Curl_read() function. Even when it gets an error from
> Curl_ssl_recv(), it returns CURLE_OK and therefor drops any track about the
> error which occurred. Is it anyhow intentional?

I can't remember doing that intentionally and I can't find any good
motivation to keep it that way. How about a patch similar to this:

--- lib/sendf.c 4 Feb 2010 19:44:31 -0000 1.163
+++ lib/sendf.c 17 Mar 2010 22:43:07 -0000
@@ -538,9 +538,10 @@ int Curl_read(struct connectdata *conn,
    if(conn->ssl[num].state == ssl_connection_complete) {
      nread = Curl_ssl_recv(conn, num, buffertofill, bytesfromsocket);

- if(nread == -1) {
+ if(nread == -1)
        return -1; /* -1 from Curl_ssl_recv() means EWOULDBLOCK */
- }
+ else if(!nread)
+ return CURLE_RECV_ERROR;
    }
    else if(Curl_ssh_enabled(conn, (PROT_SCP|PROT_SFTP))) {
      if(conn->protocol & PROT_SCP)

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-03-17