• Show log

    Commit

  • Hash : 5ca75fd5
    Author : Alex Crichton
    Date : 2016-11-10T08:00:22

    curl_stream: check for -1 after CURLINFO_LASTSOCKET
    
    We're recently trying to upgrade to the current master of libgit2
    in Cargo but we're unfortunately hitting a segfault in one of our
    tests. This particular test is just a small smoke test that https
    works (e.g. it's configured in libgit2). It attempts to clone
    from a URL which simply immediately drops connections after
    they're accepted (e.g. terminate abnormally). We expect to see a
    standard error from libgit2 but unfortunately we're seeing a
    segfault.
    
    This segfault is happening inside of the `wait_for` function of
    `curl_stream.c` at the line `FD_SET(fd, &errfd)` because `fd` is
    -1. This ends up doing an out-of-bounds array access that faults
    the program. I tracked back to where this -1 came from to the
    line here (returned by `CURLINFO_LASTSOCKET`) and added a check
    to return an error.