1 Star 0 Fork 43

pojunxing/openldap

forked from src-openEuler/openldap 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-ITS-9876-Some-more-leaks-plugged.patch 2.43 KB
一键复制 编辑 原始数据 按行查看 历史
compile_success 提交于 2022-11-07 12:04 . backport patch
From c07e961d40942635ef4b6e75e8da8b101865c148 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Kuzn=C3=ADk?= <ondra@mistotebe.net>
Date: Thu, 7 Jul 2022 16:42:10 +0100
Subject: [PATCH] ITS#9876 Some more leaks plugged
---
clients/tools/ldapsearch.c | 7 ++++---
libraries/libldap/deref.c | 15 ++++-----------
2 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c
index a0ca0d79f..02b49bd1c 100644
--- a/clients/tools/ldapsearch.c
+++ b/clients/tools/ldapsearch.c
@@ -1866,12 +1866,13 @@ again:
if ( ldapsync && sync_slimit != -1 &&
nresponses_psearch >= sync_slimit ) {
BerElement *msgidber = NULL;
- struct berval *msgidvalp = NULL;
+ struct berval msgidval;
msgidber = ber_alloc_t(LBER_USE_DER);
ber_printf(msgidber, "{i}", msgid);
- ber_flatten(msgidber, &msgidvalp);
+ ber_flatten2( msgidber, &msgidval, 0 );
ldap_extended_operation(ld, LDAP_EXOP_CANCEL,
- msgidvalp, NULL, NULL, &cancel_msgid);
+ &msgidval, NULL, NULL, &cancel_msgid);
+ ber_free( msgidber, 1 );
nresponses_psearch = -1;
}
}
diff --git a/libraries/libldap/deref.c b/libraries/libldap/deref.c
index 7d3471ad3..f187a9fd4 100644
--- a/libraries/libldap/deref.c
+++ b/libraries/libldap/deref.c
@@ -160,7 +160,8 @@ ldap_parse_derefresponse_control(
LDAPControl *ctrl,
LDAPDerefRes **drp2 )
{
- BerElement *ber;
+ BerElementBuffer berbuf;
+ BerElement *ber = (BerElement *)&berbuf;
ber_tag_t tag;
ber_len_t len;
char *last;
@@ -172,13 +173,8 @@ ldap_parse_derefresponse_control(
return LDAP_PARAM_ERROR;
}
- /* Create a BerElement from the berval returned in the control. */
- ber = ber_init( &ctrl->ldctl_value );
-
- if ( ber == NULL ) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return ld->ld_errno;
- }
+ /* Set up a BerElement from the berval returned in the control. */
+ ber_init2( ber, &ctrl->ldctl_value, 0 );
/* Extract the count and cookie from the control. */
drp = &drhead;
@@ -193,7 +189,6 @@ ldap_parse_derefresponse_control(
dr = LDAP_CALLOC( 1, sizeof(LDAPDerefRes) );
if ( dr == NULL ) {
ldap_derefresponse_free( drhead );
- ber_free( ber, 1 );
*drp2 = NULL;
ld->ld_errno = LDAP_NO_MEMORY;
return ld->ld_errno;
@@ -244,8 +239,6 @@ ldap_parse_derefresponse_control(
tag = 0;
done:;
- ber_free( ber, 1 );
-
if ( tag == LBER_ERROR ) {
if ( drhead != NULL ) {
ldap_derefresponse_free( drhead );
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chengyechun/openldap.git
git@gitee.com:chengyechun/openldap.git
chengyechun
openldap
openldap
master

搜索帮助