Skip to content

Commit f0722df

Browse files
[AUTO-CHERRYPICK] openldap: Add patch to resolve CVE-2023-2953 - branch main (#10234)
Co-authored-by: Sumynwa <sumsharma@microsoft.com>
1 parent 54b7e86 commit f0722df

2 files changed

Lines changed: 99 additions & 1 deletion

File tree

SPECS/openldap/CVE-2023-2953.patch

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
From c5c8c06a8bd52ea7b843e7d8ca961a7d1800ce5f Mon Sep 17 00:00:00 2001
2+
From: Howard Chu <hyc@openldap.org>
3+
Date: Wed, 24 Aug 2022 14:40:51 +0100
4+
Subject: [PATCH] ITS#9904 ldif_open_url: check for ber_strdup failure
5+
6+
Code present since 1999, df8f7cbb9b79be3be9205d116d1dd0b263d6861a
7+
---
8+
libraries/libldap/fetch.c | 2 ++
9+
libraries/libldap/url.c | 21 ++++++++++++---------
10+
2 files changed, 14 insertions(+), 9 deletions(-)
11+
12+
diff --git a/libraries/libldap/fetch.c b/libraries/libldap/fetch.c
13+
index cdc69b8..fe5c4e5 100644
14+
--- a/libraries/libldap/fetch.c
15+
+++ b/libraries/libldap/fetch.c
16+
@@ -69,6 +69,8 @@ ldif_open_url(
17+
}
18+
19+
p = ber_strdup( urlstr );
20+
+ if ( p == NULL )
21+
+ return NULL;
22+
23+
/* But we should convert to LDAP_DIRSEP before use */
24+
if ( LDAP_DIRSEP[0] != '/' ) {
25+
---
26+
From 6563fab9e2feccb0a684d0398e78571d09fb808b Mon Sep 17 00:00:00 2001
27+
From: Howard Chu <hyc@openldap.org>
28+
Date: Thu, 25 Aug 2022 16:13:21 +0100
29+
Subject: [PATCH] ITS#9904 ldap_url_parsehosts: check for strdup failure
30+
31+
Avoid unnecessary strdup in IPv6 addr parsing, check for strdup
32+
failure when dup'ing scheme.
33+
34+
Code present since 2000, 8da110a9e726dbc612b302feafe0109271e6bc59
35+
---
36+
diff --git a/libraries/libldap/url.c b/libraries/libldap/url.c
37+
index b39f70b..01a167d 100644
38+
--- a/libraries/libldap/url.c
39+
+++ b/libraries/libldap/url.c
40+
@@ -1357,24 +1357,22 @@ ldap_url_parsehosts(
41+
}
42+
ludp->lud_port = port;
43+
ludp->lud_host = specs[i];
44+
- specs[i] = NULL;
45+
p = strchr(ludp->lud_host, ':');
46+
if (p != NULL) {
47+
/* more than one :, IPv6 address */
48+
if ( strchr(p+1, ':') != NULL ) {
49+
/* allow [address] and [address]:port */
50+
if ( *ludp->lud_host == '[' ) {
51+
- p = LDAP_STRDUP(ludp->lud_host+1);
52+
- /* copied, make sure we free source later */
53+
- specs[i] = ludp->lud_host;
54+
- ludp->lud_host = p;
55+
- p = strchr( ludp->lud_host, ']' );
56+
+ p = strchr( ludp->lud_host+1, ']' );
57+
if ( p == NULL ) {
58+
LDAP_FREE(ludp);
59+
ldap_charray_free(specs);
60+
return LDAP_PARAM_ERROR;
61+
}
62+
- *p++ = '\0';
63+
+ /* Truncate trailing ']' and shift hostname down 1 char */
64+
+ *p = '\0';
65+
+ AC_MEMCPY( ludp->lud_host, ludp->lud_host+1, p - ludp->lud_host );
66+
+ p++;
67+
if ( *p != ':' ) {
68+
if ( *p != '\0' ) {
69+
LDAP_FREE(ludp);
70+
@@ -1400,14 +1398,19 @@ ldap_url_parsehosts(
71+
}
72+
}
73+
}
74+
- ldap_pvt_hex_unescape(ludp->lud_host);
75+
ludp->lud_scheme = LDAP_STRDUP("ldap");
76+
+ if ( ludp->lud_scheme == NULL ) {
77+
+ LDAP_FREE(ludp);
78+
+ ldap_charray_free(specs);
79+
+ return LDAP_NO_MEMORY;
80+
+ }
81+
+ specs[i] = NULL;
82+
+ ldap_pvt_hex_unescape(ludp->lud_host);
83+
ludp->lud_next = *ludlist;
84+
*ludlist = ludp;
85+
}
86+
87+
/* this should be an array of NULLs now */
88+
- /* except entries starting with [ */
89+
ldap_charray_free(specs);
90+
return LDAP_SUCCESS;
91+
}
92+
--
93+
2.25.1
94+

SPECS/openldap/openldap.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Summary: OpenLDAP (Lightweight Directory Access Protocol)
33
Name: openldap
44
Version: 2.4.57
5-
Release: 8%{?dist}
5+
Release: 9%{?dist}
66
License: OpenLDAP
77
Vendor: Microsoft Corporation
88
Distribution: Mariner
@@ -15,6 +15,7 @@ Patch1: openldap-2.4.44-consolidated-2.patch
1515
Patch2: CVE-2015-3276.patch
1616
Patch3: CVE-2021-27212.patch
1717
Patch4: CVE-2022-29155.patch
18+
Patch5: CVE-2023-2953.patch
1819
BuildRequires: cyrus-sasl-bootstrap-devel >= 2.1
1920
BuildRequires: e2fsprogs-devel
2021
BuildRequires: groff
@@ -72,6 +73,9 @@ find %{buildroot} -type f -name "*.la" -delete -print
7273
%{_sysconfdir}/openldap/*
7374

7475
%changelog
76+
* Thu Aug 22 2024 Sumedh Sharma <sumsharma@microsoft.com> - 2.4.57-9
77+
- Add patch to resolve CVE-2023-2953.
78+
7579
* Fri Feb 10 2023 Sriram Nambakam <snambakam@microsoft.com> - 2.4.57-8
7680
- Let openldap depend on cyrus-sasl.
7781

0 commit comments

Comments
 (0)