[AUTO-CHERRYPICK] openldap: Add patch to resolve CVE-2023-2953 - branch main (#10234)

Co-authored-by: Sumynwa <sumsharma@microsoft.com>
This commit is contained in:
CBL-Mariner-Bot 2024-08-23 11:39:22 -07:00 коммит произвёл GitHub
Родитель 54b7e86fd1
Коммит f0722dfa7d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 99 добавлений и 1 удалений

Просмотреть файл

@ -0,0 +1,94 @@
From c5c8c06a8bd52ea7b843e7d8ca961a7d1800ce5f Mon Sep 17 00:00:00 2001
From: Howard Chu <hyc@openldap.org>
Date: Wed, 24 Aug 2022 14:40:51 +0100
Subject: [PATCH] ITS#9904 ldif_open_url: check for ber_strdup failure
Code present since 1999, df8f7cbb9b79be3be9205d116d1dd0b263d6861a
---
libraries/libldap/fetch.c | 2 ++
libraries/libldap/url.c | 21 ++++++++++++---------
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/libraries/libldap/fetch.c b/libraries/libldap/fetch.c
index cdc69b8..fe5c4e5 100644
--- a/libraries/libldap/fetch.c
+++ b/libraries/libldap/fetch.c
@@ -69,6 +69,8 @@ ldif_open_url(
}
p = ber_strdup( urlstr );
+ if ( p == NULL )
+ return NULL;
/* But we should convert to LDAP_DIRSEP before use */
if ( LDAP_DIRSEP[0] != '/' ) {
---
From 6563fab9e2feccb0a684d0398e78571d09fb808b Mon Sep 17 00:00:00 2001
From: Howard Chu <hyc@openldap.org>
Date: Thu, 25 Aug 2022 16:13:21 +0100
Subject: [PATCH] ITS#9904 ldap_url_parsehosts: check for strdup failure
Avoid unnecessary strdup in IPv6 addr parsing, check for strdup
failure when dup'ing scheme.
Code present since 2000, 8da110a9e726dbc612b302feafe0109271e6bc59
---
diff --git a/libraries/libldap/url.c b/libraries/libldap/url.c
index b39f70b..01a167d 100644
--- a/libraries/libldap/url.c
+++ b/libraries/libldap/url.c
@@ -1357,24 +1357,22 @@ ldap_url_parsehosts(
}
ludp->lud_port = port;
ludp->lud_host = specs[i];
- specs[i] = NULL;
p = strchr(ludp->lud_host, ':');
if (p != NULL) {
/* more than one :, IPv6 address */
if ( strchr(p+1, ':') != NULL ) {
/* allow [address] and [address]:port */
if ( *ludp->lud_host == '[' ) {
- p = LDAP_STRDUP(ludp->lud_host+1);
- /* copied, make sure we free source later */
- specs[i] = ludp->lud_host;
- ludp->lud_host = p;
- p = strchr( ludp->lud_host, ']' );
+ p = strchr( ludp->lud_host+1, ']' );
if ( p == NULL ) {
LDAP_FREE(ludp);
ldap_charray_free(specs);
return LDAP_PARAM_ERROR;
}
- *p++ = '\0';
+ /* Truncate trailing ']' and shift hostname down 1 char */
+ *p = '\0';
+ AC_MEMCPY( ludp->lud_host, ludp->lud_host+1, p - ludp->lud_host );
+ p++;
if ( *p != ':' ) {
if ( *p != '\0' ) {
LDAP_FREE(ludp);
@@ -1400,14 +1398,19 @@ ldap_url_parsehosts(
}
}
}
- ldap_pvt_hex_unescape(ludp->lud_host);
ludp->lud_scheme = LDAP_STRDUP("ldap");
+ if ( ludp->lud_scheme == NULL ) {
+ LDAP_FREE(ludp);
+ ldap_charray_free(specs);
+ return LDAP_NO_MEMORY;
+ }
+ specs[i] = NULL;
+ ldap_pvt_hex_unescape(ludp->lud_host);
ludp->lud_next = *ludlist;
*ludlist = ludp;
}
/* this should be an array of NULLs now */
- /* except entries starting with [ */
ldap_charray_free(specs);
return LDAP_SUCCESS;
}
--
2.25.1

Просмотреть файл

@ -2,7 +2,7 @@
Summary: OpenLDAP (Lightweight Directory Access Protocol)
Name: openldap
Version: 2.4.57
Release: 8%{?dist}
Release: 9%{?dist}
License: OpenLDAP
Vendor: Microsoft Corporation
Distribution: Mariner
@ -15,6 +15,7 @@ Patch1: openldap-2.4.44-consolidated-2.patch
Patch2: CVE-2015-3276.patch
Patch3: CVE-2021-27212.patch
Patch4: CVE-2022-29155.patch
Patch5: CVE-2023-2953.patch
BuildRequires: cyrus-sasl-bootstrap-devel >= 2.1
BuildRequires: e2fsprogs-devel
BuildRequires: groff
@ -72,6 +73,9 @@ find %{buildroot} -type f -name "*.la" -delete -print
%{_sysconfdir}/openldap/*
%changelog
* Thu Aug 22 2024 Sumedh Sharma <sumsharma@microsoft.com> - 2.4.57-9
- Add patch to resolve CVE-2023-2953.
* Fri Feb 10 2023 Sriram Nambakam <snambakam@microsoft.com> - 2.4.57-8
- Let openldap depend on cyrus-sasl.