summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorHitendra Prajapati <hprajapati@mvista.com>2023-04-14 16:25:23 +0530
committerSteve Sakoman <steve@sakoman.com>2023-04-19 04:32:59 -1000
commit00af542d30e27be23c927ad214ffbef368ab3215 (patch)
treea3868d5df6620d6e1539b0388234a1503bfd1f12 /meta
parentbcb3c107d36958ae991773eb5ef14ed558f41737 (diff)
downloadpoky-00af542d30e27be23c927ad214ffbef368ab3215.tar.gz
curl: CVE-2023-27534 SFTP path ~ resolving discrepancy
Upstream-Status: Backport from https://github.com/curl/curl/commit/4e2b52b5f7a3bf50a0f1494155717b02cc1df6d6 (From OE-Core rev: 9aefb4e46cf4fbf14b46f9adaf3771854553e7f3) Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-support/curl/curl/CVE-2023-27534.patch123
-rw-r--r--meta/recipes-support/curl/curl_7.69.1.bb1
2 files changed, 124 insertions, 0 deletions
diff --git a/meta/recipes-support/curl/curl/CVE-2023-27534.patch b/meta/recipes-support/curl/curl/CVE-2023-27534.patch
new file mode 100644
index 0000000000..aeeffd5fea
--- /dev/null
+++ b/meta/recipes-support/curl/curl/CVE-2023-27534.patch
@@ -0,0 +1,123 @@
1From 4e2b52b5f7a3bf50a0f1494155717b02cc1df6d6 Mon Sep 17 00:00:00 2001
2From: Daniel Stenberg <daniel@haxx.se>
3Date: Thu, 9 Mar 2023 16:22:11 +0100
4Subject: [PATCH] curl_path: create the new path with dynbuf
5
6CVE: CVE-2023-27534
7Upstream-Status: Backport [https://github.com/curl/curl/commit/4e2b52b5f7a3bf50a0f1494155717b02cc1df6d6]
8
9Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
10---
11 lib/curl_path.c | 71 ++++++++++++++++++++++++-------------------------
12 1 file changed, 35 insertions(+), 36 deletions(-)
13
14diff --git a/lib/curl_path.c b/lib/curl_path.c
15index f429634..e17db4b 100644
16--- a/lib/curl_path.c
17+++ b/lib/curl_path.c
18@@ -30,6 +30,8 @@
19 #include "escape.h"
20 #include "memdebug.h"
21
22+#define MAX_SSHPATH_LEN 100000 /* arbitrary */
23+
24 /* figure out the path to work with in this particular request */
25 CURLcode Curl_getworkingpath(struct connectdata *conn,
26 char *homedir, /* when SFTP is used */
27@@ -37,60 +39,57 @@ CURLcode Curl_getworkingpath(struct connectdata *conn,
28 real path to work with */
29 {
30 struct Curl_easy *data = conn->data;
31- char *real_path = NULL;
32 char *working_path;
33 size_t working_path_len;
34+ struct dynbuf npath;
35 CURLcode result =
36 Curl_urldecode(data, data->state.up.path, 0, &working_path,
37 &working_path_len, FALSE);
38 if(result)
39 return result;
40
41+ /* new path to switch to in case we need to */
42+ Curl_dyn_init(&npath, MAX_SSHPATH_LEN);
43+
44 /* Check for /~/, indicating relative to the user's home directory */
45- if(conn->handler->protocol & CURLPROTO_SCP) {
46- real_path = malloc(working_path_len + 1);
47- if(real_path == NULL) {
48+ if((data->conn->handler->protocol & CURLPROTO_SCP) &&
49+ (working_path_len > 3) && (!memcmp(working_path, "/~/", 3))) {
50+ /* It is referenced to the home directory, so strip the leading '/~/' */
51+ if(Curl_dyn_addn(&npath, &working_path[3], working_path_len - 3)) {
52 free(working_path);
53 return CURLE_OUT_OF_MEMORY;
54 }
55- if((working_path_len > 3) && (!memcmp(working_path, "/~/", 3)))
56- /* It is referenced to the home directory, so strip the leading '/~/' */
57- memcpy(real_path, working_path + 3, working_path_len - 2);
58- else
59- memcpy(real_path, working_path, 1 + working_path_len);
60 }
61- else if(conn->handler->protocol & CURLPROTO_SFTP) {
62- if((working_path_len > 1) && (working_path[1] == '~')) {
63- size_t homelen = strlen(homedir);
64- real_path = malloc(homelen + working_path_len + 1);
65- if(real_path == NULL) {
66- free(working_path);
67- return CURLE_OUT_OF_MEMORY;
68- }
69- /* It is referenced to the home directory, so strip the
70- leading '/' */
71- memcpy(real_path, homedir, homelen);
72- real_path[homelen] = '/';
73- real_path[homelen + 1] = '\0';
74- if(working_path_len > 3) {
75- memcpy(real_path + homelen + 1, working_path + 3,
76- 1 + working_path_len -3);
77- }
78+ else if((data->conn->handler->protocol & CURLPROTO_SFTP) &&
79+ (working_path_len > 2) && !memcmp(working_path, "/~/", 3)) {
80+ size_t len;
81+ const char *p;
82+ int copyfrom = 3;
83+ if(Curl_dyn_add(&npath, homedir)) {
84+ free(working_path);
85+ return CURLE_OUT_OF_MEMORY;
86 }
87- else {
88- real_path = malloc(working_path_len + 1);
89- if(real_path == NULL) {
90- free(working_path);
91- return CURLE_OUT_OF_MEMORY;
92- }
93- memcpy(real_path, working_path, 1 + working_path_len);
94+ /* Copy a separating '/' if homedir does not end with one */
95+ len = Curl_dyn_len(&npath);
96+ p = Curl_dyn_ptr(&npath);
97+ if(len && (p[len-1] != '/'))
98+ copyfrom = 2;
99+
100+ if(Curl_dyn_addn(&npath,
101+ &working_path[copyfrom], working_path_len - copyfrom)) {
102+ free(working_path);
103+ return CURLE_OUT_OF_MEMORY;
104 }
105 }
106
107- free(working_path);
108+ if(Curl_dyn_len(&npath)) {
109+ free(working_path);
110
111- /* store the pointer for the caller to receive */
112- *path = real_path;
113+ /* store the pointer for the caller to receive */
114+ *path = Curl_dyn_ptr(&npath);
115+ }
116+ else
117+ *path = working_path;
118
119 return CURLE_OK;
120 }
121--
1222.25.1
123
diff --git a/meta/recipes-support/curl/curl_7.69.1.bb b/meta/recipes-support/curl/curl_7.69.1.bb
index 64e4fb5809..a7f4f5748f 100644
--- a/meta/recipes-support/curl/curl_7.69.1.bb
+++ b/meta/recipes-support/curl/curl_7.69.1.bb
@@ -43,6 +43,7 @@ SRC_URI = "https://curl.haxx.se/download/curl-${PV}.tar.bz2 \
43 file://CVE-2022-35260.patch \ 43 file://CVE-2022-35260.patch \
44 file://CVE-2022-43552.patch \ 44 file://CVE-2022-43552.patch \
45 file://CVE-2023-23916.patch \ 45 file://CVE-2023-23916.patch \
46 file://CVE-2023-27534.patch \
46" 47"
47 48
48SRC_URI[md5sum] = "ec5fc263f898a3dfef08e805f1ecca42" 49SRC_URI[md5sum] = "ec5fc263f898a3dfef08e805f1ecca42"