Menu

#1180 libcurl can trigger a SIGPIPE

closed-fixed
4
2014-08-16
2013-01-08
No

Using 7.28.1 and current git (jan 8, 2013) libcurl can cause a SIGPIPE to trigger. One situation was possible to trigger with this command line using a libcurl built to use OpenSSL:

$ curl --limit-rate 250k -L http://github.com/raspberrypi/firmware/archive/4ade27942e.tar.gz > /dev/null

This command redirects to a HTTPS site and then to a second site that it downloads from. When after the (5+ minutes) download the initial HTTPS connection is to be shut down, the OpenSSL calls used will attempt an SSL shutdown but the server has already closed the connection and this triggers a SIGPIPE.

OpenSSL (and quite probably a few of the other SSL backends) does not allow us to easily switch off SIGPIPE generation on systems without SO_NOSIGPIPE.

The only suitable way to do it that will work is to

On the library entry call: check if ignore of the signal is necessary, then ignore it.

When leaving the library again: check if libcurl set the ignore, then remove it again.

Inspirational code for this kind of functionality can be seen here: https://github.com/kroki/XProbes/blob/1447f3d93b6dbf273919af15e59f35cca58fcc23/src/libxprobes.c#L156 - note that the XProbes code is LGPL licensed.

Originally reported here: http://curl.haxx.se/mail/archive-2013-01/0003.html by Lluís Batlle i Rossell

Discussion

  • Daniel Stenberg

    Daniel Stenberg - 2013-03-11

    I posted my suggested libcurl fix for this just now, stored here:

    http://curl.haxx.se/mail/lib-2013-03/0122.html

     
  • Daniel Stenberg

    Daniel Stenberg - 2013-04-01

    Lowered prio because this is a very old bug that rarely hits someone badly. The patch has received very few comments.

     
  • Daniel Stenberg

    Daniel Stenberg - 2013-04-01
    • milestone: --> not_used
    • priority: 5 --> 4
     
  • David R. Sullivan

    I think you should release this change at a higher priority, we still have it in a couple of cases and it has made me pull out libCurl usage in one case.

     
  • Daniel Stenberg

    Daniel Stenberg - 2013-06-03

    David: so does the patch fix the problem you experienced?

     
  • David R. Sullivan

    I will know soon.

     

    Last edit: Daniel Stenberg 2013-06-16
  • Daniel Stenberg

    Daniel Stenberg - 2013-06-20

    This patch will not be merged in time for the 7.31.0 release but hopefully immediately after to get wider testing and acceptance before becoming a part of an official release.

     
  • Daniel Stenberg

    Daniel Stenberg - 2013-06-22
    • labels: --> openssl, SSL/TLS
    • status: open-confirmed --> closed-fixed
     
  • Daniel Stenberg

    Daniel Stenberg - 2013-06-22

    Thanks for the report. This is now fixed and pushed as commit 7d80ed64e435155.