cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Bug: curl doesn't notice ENOSPACE if it writes a small amount of data.

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 23 Nov 2009 15:00:15 +0100 (CET)

On Mon, 23 Nov 2009, Björn Augustsson wrote:

> $ curl -o short google.com
> % Total % Received % Xferd Average Speed Time Time Time Current
> Dload Upload Total Spent Left Speed
> 109 219 109 219 0 0 571 0 --:--:-- --:--:-- --:--:-- 1183
> $
>
> ## So... All went well? Nope:

Thanks for this report.

I managed to repeat it exactly as you mentioned. And you know what? fwrite()
returns a successful return code on that single 219 byte write, so libcurl
doesn't discover any problem!

With strace we can see that the underlying write() function gets a -1
(ENOSPACE) back, but that doesn't help us much...

The fix turned out to be that we didn't do the proper error-checking on the
fclose() call, which got the error reported. While fixing this, I noticed a
similarly lack of error check on a fflush() call that I also added while
editing the code.

So, the version in CVS now detects this failure and reports it!

-- 
  / daniel.haxx.se

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-11-23