diff options
author | Daniel Stenberg <daniel@haxx.se> | 2023-05-02 10:25:58 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2023-05-02 13:24:30 +0200 |
commit | d8df0d6db7441b6e14920a7e16a10e32bdc9c7ae (patch) | |
tree | aa407dc14b9763a97b57dca7101fa51f57ac8da6 | |
parent | b8d7746e3c035c50255907603974884fd39b57b6 (diff) | |
download | curl-d8df0d6db7441b6e14920a7e16a10e32bdc9c7ae.tar.gz |
easy_cleanup: require a "good" handle to act
By insisting that the passed in handle is "good" (the magic number is
intact), this can limit the potential damage if a bad pointer is passed
in. Like when this function is called twice on the same handle pointer.
Ref: #10964
Closes #11061
-rw-r--r-- | lib/easy.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/easy.c b/lib/easy.c index a6c32f51e..d72a2a88d 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -787,14 +787,12 @@ CURLcode curl_easy_perform_ev(struct Curl_easy *data) */ void curl_easy_cleanup(struct Curl_easy *data) { - SIGPIPE_VARIABLE(pipe_st); - - if(!data) - return; - - sigpipe_ignore(data, &pipe_st); - Curl_close(&data); - sigpipe_restore(&pipe_st); + if(GOOD_EASY_HANDLE(data)) { + SIGPIPE_VARIABLE(pipe_st); + sigpipe_ignore(data, &pipe_st); + Curl_close(&data); + sigpipe_restore(&pipe_st); + } } /* |