]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
easy_cleanup: require a "good" handle to act
authorDaniel Stenberg <daniel@haxx.se>
Tue, 2 May 2023 08:25:58 +0000 (10:25 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 2 May 2023 11:24:30 +0000 (13:24 +0200)
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

lib/easy.c

index a6c32f51e6d1fbd032bfa465b18510dab63c30e0..d72a2a88d3c1c0f8edf1e3c1adc06b7f7d5f6c5f 100644 (file)
@@ -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);
+  }
 }
 
 /*