<pre style='margin:0'>
Joshua Root (jmroot) pushed a commit to branch master
in repository macports-base.

</pre>
<p><a href="https://github.com/macports/macports-base/commit/1ac551fcd29eb5f24b80a6b8e9198b262f1d4938">https://github.com/macports/macports-base/commit/1ac551fcd29eb5f24b80a6b8e9198b262f1d4938</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/master by this push:
<span style='display:block; white-space:pre;color:#404040;'>     new 1ac551fcd Better curl crash workaround
</span>1ac551fcd is described below

<span style='display:block; white-space:pre;color:#808000;'>commit 1ac551fcd29eb5f24b80a6b8e9198b262f1d4938
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Sun Sep 22 11:25:18 2024 +1000

<span style='display:block; white-space:pre;color:#404040;'>    Better curl crash workaround
</span><span style='display:block; white-space:pre;color:#404040;'>    
</span><span style='display:block; white-space:pre;color:#404040;'>    Clean up and reallocate the multi handle if either the URL scheme or
</span><span style='display:block; white-space:pre;color:#404040;'>    host changed from the previous transfer.
</span><span style='display:block; white-space:pre;color:#404040;'>    
</span><span style='display:block; white-space:pre;color:#404040;'>    See: https://trac.macports.org/ticket/70764
</span>---
 src/pextlib1.0/curl.c | 106 ++++++++++++++++++++++++++++----------------------
 1 file changed, 60 insertions(+), 46 deletions(-)

<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/pextlib1.0/curl.c b/src/pextlib1.0/curl.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 4edacd2a2..d079f34e5 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/pextlib1.0/curl.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/pextlib1.0/curl.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -159,6 +159,62 @@ SetResultFromCurlMErrorCode(Tcl_Interp *interp, CURLMcode inErrorCode)
</span>   return result;
 }
 
<span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Bug affecting some versions of Monterey through Sequoia:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+   reusing an easy handle for different protocols can cause a
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+   crash. https://github.com/curl/curl/issues/13731
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+   TODO: Add upper bound here when we know what version macOS 16 ships. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if LIBCURL_VERSION_NUM >= 0x074d00
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+static void cleanup_handle_if_needed(const char *theURL);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+static void cleanup_handle_if_needed(const char *theURL)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    static CURLU *currentURLHandle = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    static CURLU *previousURLHandle = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    set_curl_version_info();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    if (libcurl_version_info == NULL) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        fprintf(stderr, "Warning: set_curl_version_info failed\n");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    if (libcurl_version_info->version_num >= 0x080600 && libcurl_version_info->version_num < 0x080800) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        if (previousURLHandle != NULL) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            curl_url_cleanup(previousURLHandle);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        previousURLHandle = currentURLHandle;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        currentURLHandle = curl_url();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+         if (currentURLHandle != NULL
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            && curl_url_set(currentURLHandle, CURLUPART_URL, theURL, 0) != CURLUE_OK) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            curl_url_cleanup(currentURLHandle);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            currentURLHandle = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        if (theMHandle != NULL && currentURLHandle != NULL && previousURLHandle != NULL) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            char *current_scheme = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            char *previous_scheme = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            char *current_host = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            char *previous_host = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            int must_recreate_handle = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            if (curl_url_get(previousURLHandle, CURLUPART_SCHEME, &previous_scheme, 0) == CURLUE_OK
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                && curl_url_get(currentURLHandle, CURLUPART_SCHEME, &current_scheme, 0) == CURLUE_OK
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                && 0 != strcasecmp(previous_scheme, current_scheme)) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                must_recreate_handle = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            if (!must_recreate_handle
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                && curl_url_get(previousURLHandle, CURLUPART_HOST, &previous_host, 0) == CURLUE_OK
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                && curl_url_get(currentURLHandle, CURLUPART_HOST, &current_host, 0) == CURLUE_OK
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                && 0 != strcasecmp(previous_host, current_host)) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                must_recreate_handle = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            if (must_recreate_handle) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                /* deallocate the handle and start again */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                curl_multi_cleanup(theMHandle);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                theMHandle = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* LIBCURL_VERSION_NUM >= 0x074d00 */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> /**
  * curl fetch subcommand entry point.
  *
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -209,9 +265,6 @@ CurlFetchCmd(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[])
</span>           struct CURLMsg *info = NULL;
                int running; /* number of running transfers */
                char* acceptEncoding = NULL;
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#if LIBCURL_VERSION_NUM >= 0x074d00
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-           char *previous_scheme = NULL;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif
</span> 
                /* we might have options and then the url and the file */
                /* let's process the options first */
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -337,6 +390,10 @@ CurlFetchCmd(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[])
</span>                   break;
                }
 
<span style='display:block; white-space:pre;background:#e0ffe0;'>+#if LIBCURL_VERSION_NUM >= 0x074d00
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+           cleanup_handle_if_needed(theURL);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span>           /* Create the CURL handles */
                if (theMHandle == NULL) {
                        /* Re-use existing multi handle if theMHandle isn't NULL */
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -357,22 +414,6 @@ CurlFetchCmd(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[])
</span>                           break;
                        }
                }
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#if LIBCURL_VERSION_NUM >= 0x074d00
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-        else {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-            set_curl_version_info();
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-            if (libcurl_version_info == NULL) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                theResult = TCL_ERROR;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                Tcl_SetResult(interp, "set_curl_version_info failed", TCL_STATIC);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                break;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-            }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-            /* for mitigation of reused handle bug - see below */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-            if (libcurl_version_info->version_num >= 0x080600 && libcurl_version_info->version_num < 0x080800) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                if (curl_easy_getinfo(theHandle, CURLINFO_SCHEME, &previous_scheme) != CURLE_OK) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                    previous_scheme = NULL;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-            }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-        }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif
</span>           /* If we're re-using a handle, the previous call did ensure to reset it
                 * to the default state using curl_easy_reset(3) */
 
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -383,33 +424,6 @@ CurlFetchCmd(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[])
</span>                   break;
                }
 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-        /* Bug affecting some macOS releases (Monterey through Sequoia):
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-           reusing an easy handle for different protocols can cause a
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-           crash. https://github.com/curl/curl/issues/13731
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-           TODO: Add upper bound here when we know what version macOS 16 ships. */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#if LIBCURL_VERSION_NUM >= 0x074d00
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-        if (previous_scheme != NULL) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-            char *current_scheme = NULL;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-            if (curl_easy_getinfo(theHandle, CURLINFO_SCHEME, &current_scheme) == CURLE_OK
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                && current_scheme != NULL && 0 != strcasecmp(previous_scheme, current_scheme)) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                /* deallocate the handle and start again */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                curl_easy_cleanup(theHandle);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                theHandle = NULL;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                theHandle = curl_easy_init();
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                if (theHandle == NULL) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                    theResult = TCL_ERROR;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                    Tcl_SetResult(interp, "error in curl_easy_init", TCL_STATIC);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                    break;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                theCurlCode = curl_easy_setopt(theHandle, CURLOPT_URL, theURL);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                if (theCurlCode != CURLE_OK) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                    theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                    break;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-            }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-        }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> #if LIBCURL_VERSION_NUM >= 0x071304 && LIBCURL_VERSION_NUM <= 0x071307
                /* FTP_PROXY workaround for Snow Leopard */
                if (strncmp(theURL, "ftp:", 4) == 0) {
</pre><pre style='margin:0'>

</pre>