diff options
| author | Mingli Yu <mingli.yu@windriver.com> | 2024-09-24 16:45:03 +0800 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2024-10-07 05:43:22 -0700 |
| commit | e54070cd37fd01efa6b195ee72b965a028d63fe4 (patch) | |
| tree | 3c758e34d2f836b6e9b4edc8c00fd0e0e6e6e729 | |
| parent | d0eef85d3354cfdc1b31e645c785e5b5eb4fa581 (diff) | |
| download | poky-e54070cd37fd01efa6b195ee72b965a028d63fe4.tar.gz | |
curl: free old conn better on reuse
Backport a patch [1] to free old conn better on reuse to
fix the memory leak issue [2].
[1] https://github.com/curl/curl/commit/06d1210
[2] https://github.com/curl/curl/issues/8841
(From OE-Core rev: fbb820cdfc480e2481d51b9a1057454832f02b23)
Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
| -rw-r--r-- | meta/recipes-support/curl/curl/0001-url-free-old-conn-better-on-reuse.patch | 95 | ||||
| -rw-r--r-- | meta/recipes-support/curl/curl_7.82.0.bb | 1 |
2 files changed, 96 insertions, 0 deletions
diff --git a/meta/recipes-support/curl/curl/0001-url-free-old-conn-better-on-reuse.patch b/meta/recipes-support/curl/curl/0001-url-free-old-conn-better-on-reuse.patch new file mode 100644 index 0000000000..520fd01b5e --- /dev/null +++ b/meta/recipes-support/curl/curl/0001-url-free-old-conn-better-on-reuse.patch | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | From 06d12105c7aa883a62802e36eebb76d5303247d0 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Daniel Stenberg <daniel@haxx.se> | ||
| 3 | Date: Sat, 14 May 2022 18:04:46 +0200 | ||
| 4 | Subject: [PATCH] url: free old conn better on reuse | ||
| 5 | |||
| 6 | Make use of conn_free() better and avoid duplicate code. | ||
| 7 | |||
| 8 | Reported-by: Andrea Pappacoda | ||
| 9 | Fixes #8841 | ||
| 10 | Closes #8842 | ||
| 11 | |||
| 12 | Upstream-Status: Backport [https://github.com/curl/curl/commit/06d12105c7aa883a62802e36eebb76d5303247d0] | ||
| 13 | |||
| 14 | Signed-off-by: Mingli Yu <mingli.yu@windriver.com> | ||
| 15 | --- | ||
| 16 | lib/url.c | 34 ++++------------------------------ | ||
| 17 | 1 file changed, 4 insertions(+), 30 deletions(-) | ||
| 18 | |||
| 19 | diff --git a/lib/url.c b/lib/url.c | ||
| 20 | index 631e49696..c2d9e78f4 100644 | ||
| 21 | --- a/lib/url.c | ||
| 22 | +++ b/lib/url.c | ||
| 23 | @@ -3498,17 +3498,6 @@ static void reuse_conn(struct Curl_easy *data, | ||
| 24 | **established** from the primary socket to a remote address. */ | ||
| 25 | char local_ip[MAX_IPADR_LEN] = ""; | ||
| 26 | int local_port = -1; | ||
| 27 | -#ifndef CURL_DISABLE_PROXY | ||
| 28 | - Curl_free_idnconverted_hostname(&old_conn->http_proxy.host); | ||
| 29 | - Curl_free_idnconverted_hostname(&old_conn->socks_proxy.host); | ||
| 30 | - | ||
| 31 | - free(old_conn->http_proxy.host.rawalloc); | ||
| 32 | - free(old_conn->socks_proxy.host.rawalloc); | ||
| 33 | - Curl_free_primary_ssl_config(&old_conn->proxy_ssl_config); | ||
| 34 | -#endif | ||
| 35 | - /* free the SSL config struct from this connection struct as this was | ||
| 36 | - allocated in vain and is targeted for destruction */ | ||
| 37 | - Curl_free_primary_ssl_config(&old_conn->ssl_config); | ||
| 38 | |||
| 39 | /* get the user+password information from the old_conn struct since it may | ||
| 40 | * be new for this request even when we re-use an existing connection */ | ||
| 41 | @@ -3539,20 +3528,17 @@ static void reuse_conn(struct Curl_easy *data, | ||
| 42 | old_conn->http_proxy.passwd = NULL; | ||
| 43 | old_conn->socks_proxy.passwd = NULL; | ||
| 44 | } | ||
| 45 | - Curl_safefree(old_conn->http_proxy.user); | ||
| 46 | - Curl_safefree(old_conn->socks_proxy.user); | ||
| 47 | - Curl_safefree(old_conn->http_proxy.passwd); | ||
| 48 | - Curl_safefree(old_conn->socks_proxy.passwd); | ||
| 49 | #endif | ||
| 50 | |||
| 51 | - /* host can change, when doing keepalive with a proxy or if the case is | ||
| 52 | - different this time etc */ | ||
| 53 | Curl_free_idnconverted_hostname(&conn->host); | ||
| 54 | Curl_free_idnconverted_hostname(&conn->conn_to_host); | ||
| 55 | Curl_safefree(conn->host.rawalloc); | ||
| 56 | Curl_safefree(conn->conn_to_host.rawalloc); | ||
| 57 | conn->host = old_conn->host; | ||
| 58 | + old_conn->host.rawalloc = NULL; | ||
| 59 | + old_conn->host.encalloc = NULL; | ||
| 60 | conn->conn_to_host = old_conn->conn_to_host; | ||
| 61 | + old_conn->conn_to_host.rawalloc = NULL; | ||
| 62 | conn->conn_to_port = old_conn->conn_to_port; | ||
| 63 | conn->remote_port = old_conn->remote_port; | ||
| 64 | Curl_safefree(conn->hostname_resolve); | ||
| 65 | @@ -3572,15 +3558,7 @@ static void reuse_conn(struct Curl_easy *data, | ||
| 66 | /* re-use init */ | ||
| 67 | conn->bits.reuse = TRUE; /* yes, we're re-using here */ | ||
| 68 | |||
| 69 | - Curl_safefree(old_conn->user); | ||
| 70 | - Curl_safefree(old_conn->passwd); | ||
| 71 | - Curl_safefree(old_conn->options); | ||
| 72 | - Curl_safefree(old_conn->localdev); | ||
| 73 | - Curl_llist_destroy(&old_conn->easyq, NULL); | ||
| 74 | - | ||
| 75 | -#ifdef USE_UNIX_SOCKETS | ||
| 76 | - Curl_safefree(old_conn->unix_domain_socket); | ||
| 77 | -#endif | ||
| 78 | + conn_free(old_conn); | ||
| 79 | } | ||
| 80 | |||
| 81 | /** | ||
| 82 | @@ -3930,10 +3908,6 @@ static CURLcode create_conn(struct Curl_easy *data, | ||
| 83 | * allocated before we can move along and use the previously existing one. | ||
| 84 | */ | ||
| 85 | reuse_conn(data, conn, conn_temp); | ||
| 86 | -#ifdef USE_SSL | ||
| 87 | - free(conn->ssl_extra); | ||
| 88 | -#endif | ||
| 89 | - free(conn); /* we don't need this anymore */ | ||
| 90 | conn = conn_temp; | ||
| 91 | *in_connect = conn; | ||
| 92 | |||
| 93 | -- | ||
| 94 | 2.34.1 | ||
| 95 | |||
diff --git a/meta/recipes-support/curl/curl_7.82.0.bb b/meta/recipes-support/curl/curl_7.82.0.bb index a613e93780..ba3abadac9 100644 --- a/meta/recipes-support/curl/curl_7.82.0.bb +++ b/meta/recipes-support/curl/curl_7.82.0.bb | |||
| @@ -61,6 +61,7 @@ SRC_URI = "https://curl.se/download/${BP}.tar.xz \ | |||
| 61 | file://CVE-2024-7264_1.patch \ | 61 | file://CVE-2024-7264_1.patch \ |
| 62 | file://CVE-2024-7264_2.patch \ | 62 | file://CVE-2024-7264_2.patch \ |
| 63 | file://CVE-2024-8096.patch \ | 63 | file://CVE-2024-8096.patch \ |
| 64 | file://0001-url-free-old-conn-better-on-reuse.patch \ | ||
| 64 | " | 65 | " |
| 65 | SRC_URI[sha256sum] = "0aaa12d7bd04b0966254f2703ce80dd5c38dbbd76af0297d3d690cdce58a583c" | 66 | SRC_URI[sha256sum] = "0aaa12d7bd04b0966254f2703ce80dd5c38dbbd76af0297d3d690cdce58a583c" |
| 66 | 67 | ||
