Skip to content

Commit 0dd6087

Browse files
[AUTO-CHERRYPICK] Patch CVE-2023-27534 in cmake - branch main (#10509)
Co-authored-by: suresh-thelkar <suresh.thelkar@yahoo.com>
1 parent 6f47c6b commit 0dd6087

5 files changed

Lines changed: 189 additions & 5 deletions

File tree

SPECS/cmake/CVE-2023-27533.patch

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
From 7aee1a49cb796ad199f02746222808d3313fbe9b Mon Sep 17 00:00:00 2001
2+
From: Suresh Thelkar <sthelkar@microsoft.com>
3+
Date: Tue, 17 Sep 2024 12:38:59 +0530
4+
Subject: [PATCH] Backporting patch for CVE-2023-27533
5+
6+
Upstream patch details are given below.
7+
https://github.com/curl/curl/pull/10728/commits
8+
---
9+
Utilities/cmcurl/lib/telnet.c | 21 +++++++++++++++++++++
10+
1 file changed, 21 insertions(+)
11+
12+
diff --git a/Utilities/cmcurl/lib/telnet.c b/Utilities/cmcurl/lib/telnet.c
13+
index fdd137fb..c8af4c95 100644
14+
--- a/Utilities/cmcurl/lib/telnet.c
15+
+++ b/Utilities/cmcurl/lib/telnet.c
16+
@@ -770,6 +770,17 @@ static void printsub(struct Curl_easy *data,
17+
}
18+
}
19+
20+
+static bool str_is_nonascii(const char *str)
21+
+{
22+
+ size_t len = strlen(str);
23+
+ while(len--) {
24+
+ if(*str & 0x80)
25+
+ return TRUE;
26+
+ str++;
27+
+ }
28+
+ return FALSE;
29+
+}
30+
+
31+
static CURLcode check_telnet_options(struct Curl_easy *data)
32+
{
33+
struct curl_slist *head;
34+
@@ -784,6 +795,8 @@ static CURLcode check_telnet_options(struct Curl_easy *data)
35+
/* Add the user name as an environment variable if it
36+
was given on the command line */
37+
if(conn->bits.user_passwd) {
38+
+ if(str_is_nonascii(conn->user))
39+
+ return CURLE_BAD_FUNCTION_ARGUMENT;
40+
msnprintf(option_arg, sizeof(option_arg), "USER,%s", conn->user);
41+
beg = curl_slist_append(tn->telnet_vars, option_arg);
42+
if(!beg) {
43+
@@ -796,6 +809,14 @@ static CURLcode check_telnet_options(struct Curl_easy *data)
44+
}
45+
46+
for(head = data->set.telnet_options; head; head = head->next) {
47+
+ char *option = head->data;
48+
+ char *arg;
49+
+ char *sep = strchr(option, '=');
50+
+ if(sep) {
51+
+ arg = ++sep;
52+
+ if(str_is_nonascii(arg))
53+
+ continue;
54+
+ }
55+
if(sscanf(head->data, "%127[^= ]%*[ =]%255s",
56+
option_keyword, option_arg) == 2) {
57+
58+
--
59+
2.34.1
60+

SPECS/cmake/CVE-2023-27534.patch

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
From 851e92133dcb67015af8f7d3402fb58fa5df051e Mon Sep 17 00:00:00 2001
2+
From: Suresh Thelkar <sthelkar@microsoft.com>
3+
Date: Wed, 18 Sep 2024 15:14:00 +0530
4+
Subject: [PATCH] Patch for CVE-2023-27534
5+
6+
Upstream patch details are given below.
7+
https://github.com/curl/curl/pull/10729/commits/01345b13d4c4d1222387f5c02dfb6244a9cade33#diff-86c8ab4ca5332fd50f646ad37656e92fc41839ba34e0ddab1ec7728439cbe5f1
8+
---
9+
Utilities/cmcurl/lib/curl_path.c | 72 ++++++++++++++++----------------
10+
1 file changed, 36 insertions(+), 36 deletions(-)
11+
12+
diff --git a/Utilities/cmcurl/lib/curl_path.c b/Utilities/cmcurl/lib/curl_path.c
13+
index 65106188..28eb41ad 100644
14+
--- a/Utilities/cmcurl/lib/curl_path.c
15+
+++ b/Utilities/cmcurl/lib/curl_path.c
16+
@@ -30,6 +30,8 @@
17+
#include "escape.h"
18+
#include "memdebug.h"
19+
20+
+#define MAX_SSHPATH_LEN 100000 /* arbitrary */
21+
+
22+
/* figure out the path to work with in this particular request */
23+
CURLcode Curl_getworkingpath(struct Curl_easy *data,
24+
char *homedir, /* when SFTP is used */
25+
@@ -39,57 +41,55 @@ CURLcode Curl_getworkingpath(struct Curl_easy *data,
26+
char *real_path = NULL;
27+
char *working_path;
28+
size_t working_path_len;
29+
+ struct dynbuf npath;
30+
CURLcode result =
31+
Curl_urldecode(data, data->state.up.path, 0, &working_path,
32+
&working_path_len, REJECT_ZERO);
33+
if(result)
34+
return result;
35+
36+
+ /* new path to switch to in case we need to */
37+
+ Curl_dyn_init(&npath, MAX_SSHPATH_LEN);
38+
+
39+
/* Check for /~/, indicating relative to the user's home directory */
40+
- if(data->conn->handler->protocol & CURLPROTO_SCP) {
41+
- real_path = malloc(working_path_len + 1);
42+
- if(!real_path) {
43+
+ if((data->conn->handler->protocol & CURLPROTO_SCP) &&
44+
+ (working_path_len > 3) && (!memcmp(working_path, "/~/", 3))) {
45+
+ /* It is referenced to the home directory, so strip the leading '/~/' */
46+
+ if(Curl_dyn_addn(&npath, &working_path[3], working_path_len - 3)) {
47+
free(working_path);
48+
return CURLE_OUT_OF_MEMORY;
49+
}
50+
- if((working_path_len > 3) && (!memcmp(working_path, "/~/", 3)))
51+
- /* It is referenced to the home directory, so strip the leading '/~/' */
52+
- memcpy(real_path, working_path + 3, working_path_len - 2);
53+
- else
54+
- memcpy(real_path, working_path, 1 + working_path_len);
55+
}
56+
- else if(data->conn->handler->protocol & CURLPROTO_SFTP) {
57+
- if((working_path_len > 1) && (working_path[1] == '~')) {
58+
- size_t homelen = strlen(homedir);
59+
- real_path = malloc(homelen + working_path_len + 1);
60+
- if(!real_path) {
61+
- free(working_path);
62+
- return CURLE_OUT_OF_MEMORY;
63+
- }
64+
- /* It is referenced to the home directory, so strip the
65+
- leading '/' */
66+
- memcpy(real_path, homedir, homelen);
67+
- real_path[homelen] = '/';
68+
- real_path[homelen + 1] = '\0';
69+
- if(working_path_len > 3) {
70+
- memcpy(real_path + homelen + 1, working_path + 3,
71+
- 1 + working_path_len -3);
72+
- }
73+
+ else if((data->conn->handler->protocol & CURLPROTO_SFTP) &&
74+
+ (working_path_len > 2) && !memcmp(working_path, "/~/", 3)) {
75+
+ size_t len;
76+
+ const char *p;
77+
+ int copyfrom = 3;
78+
+ if(Curl_dyn_add(&npath, homedir)) {
79+
+ free(working_path);
80+
+ return CURLE_OUT_OF_MEMORY;
81+
}
82+
- else {
83+
- real_path = malloc(working_path_len + 1);
84+
- if(!real_path) {
85+
- free(working_path);
86+
- return CURLE_OUT_OF_MEMORY;
87+
- }
88+
- memcpy(real_path, working_path, 1 + working_path_len);
89+
+ /* Copy a separating '/' if homedir does not end with one */
90+
+ len = Curl_dyn_len(&npath);
91+
+ p = Curl_dyn_ptr(&npath);
92+
+ if(len && (p[len-1] != '/'))
93+
+ copyfrom = 2;
94+
+
95+
+ if(Curl_dyn_addn(&npath,
96+
+ &working_path[copyfrom], working_path_len - copyfrom)) {
97+
+ free(working_path);
98+
+ return CURLE_OUT_OF_MEMORY;
99+
}
100+
}
101+
102+
- free(working_path);
103+
-
104+
- /* store the pointer for the caller to receive */
105+
- *path = real_path;
106+
+ if(Curl_dyn_len(&npath)) {
107+
+ free(working_path);
108+
+
109+
+ /* store the pointer for the caller to receive */
110+
+ *path = Curl_dyn_ptr(&npath);
111+
+ }
112+
+ else
113+
+ *path = working_path
114+
115+
return CURLE_OK;
116+
}
117+
--
118+
2.34.1
119+

SPECS/cmake/cmake.spec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Summary: Cmake
33
Name: cmake
44
Version: 3.21.4
5-
Release: 11%{?dist}
5+
Release: 12%{?dist}
66
License: BSD AND LGPLv2+
77
Vendor: Microsoft Corporation
88
Distribution: Mariner
@@ -21,6 +21,8 @@ Patch6: CVE-2023-38545.patch
2121
Patch7: CVE-2023-38546.patch
2222
Patch8: cve-2023-44487.patch
2323
Patch9: CVE-2023-28320.patch
24+
Patch10: CVE-2023-27533.patch
25+
Patch11: CVE-2023-27534.patch
2426
BuildRequires: bzip2
2527
BuildRequires: bzip2-devel
2628
BuildRequires: curl
@@ -86,6 +88,9 @@ bin/ctest --force-new-ctest-process --rerun-failed --output-on-failure
8688
%{_prefix}/doc/%{name}-*/*
8789

8890
%changelog
91+
* Wed Sep 18 2024 Suresh Thelkar <sthelkar@microsoft.com> - 3.21.4-12
92+
- Patch CVE-2023-27533 and CVE-2023-27534
93+
8994
* Fri Jul 26 2024 Zhichun Wan <zhichunwan@microsoft.com> - 3.21.4-11
9095
- Patch CVE-2023-28320.patch
9196

toolkit/resources/manifests/package/toolchain_aarch64.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ check-debuginfo-0.15.2-1.cm2.aarch64.rpm
3030
chkconfig-1.20-4.cm2.aarch64.rpm
3131
chkconfig-debuginfo-1.20-4.cm2.aarch64.rpm
3232
chkconfig-lang-1.20-4.cm2.aarch64.rpm
33-
cmake-3.21.4-11.cm2.aarch64.rpm
34-
cmake-debuginfo-3.21.4-11.cm2.aarch64.rpm
33+
cmake-3.21.4-12.cm2.aarch64.rpm
34+
cmake-debuginfo-3.21.4-12.cm2.aarch64.rpm
3535
coreutils-8.32-7.cm2.aarch64.rpm
3636
coreutils-debuginfo-8.32-7.cm2.aarch64.rpm
3737
coreutils-lang-8.32-7.cm2.aarch64.rpm

toolkit/resources/manifests/package/toolchain_x86_64.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ check-debuginfo-0.15.2-1.cm2.x86_64.rpm
3131
chkconfig-1.20-4.cm2.x86_64.rpm
3232
chkconfig-debuginfo-1.20-4.cm2.x86_64.rpm
3333
chkconfig-lang-1.20-4.cm2.x86_64.rpm
34-
cmake-3.21.4-11.cm2.x86_64.rpm
35-
cmake-debuginfo-3.21.4-11.cm2.x86_64.rpm
34+
cmake-3.21.4-12.cm2.x86_64.rpm
35+
cmake-debuginfo-3.21.4-12.cm2.x86_64.rpm
3636
coreutils-8.32-7.cm2.x86_64.rpm
3737
coreutils-debuginfo-8.32-7.cm2.x86_64.rpm
3838
coreutils-lang-8.32-7.cm2.x86_64.rpm

0 commit comments

Comments
 (0)