Issue 8001 - Segmentation Fault in ldap_sync_*
Summary: Segmentation Fault in ldap_sync_*
Status: VERIFIED FIXED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: 2.4.40
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-10 19:59 UTC by alexey@kireyev.name
Modified: 2015-07-02 17:45 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description alexey@kireyev.name 2014-12-10 19:59:34 UTC
Full_Name: Alexey Kireyev
Version: 2.4.40
OS: Ubuntu 14.04
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (98.118.88.65)


If not all fields in ldap_sync_t manually set after ldap_sync_initialize, then
any following calls might (and most  probably will) ends in segmentation fault.

Reason: ldap_sync_initialize doesn't zeroed newly allocated structure (it does
it for pre-existing, though, which is wrong by itself in my view)




--------------------------------------------------------------------------------------------------------


From 01149a2eba9f463261d88e5a1ce43e19c4a323cf Mon Sep 17 00:00:00 2001
From: Alexey Kireyev <alexey@kireyev.name>
Date: Wed, 10 Dec 2014 14:37:16 -0500
Subject: [PATCH] Newly allocated ldap_sync_t has to be zero out

---
 libraries/libldap/ldap_sync.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libraries/libldap/ldap_sync.c b/libraries/libldap/ldap_sync.c
index e573c3b..e79153f 100644
--- a/libraries/libldap/ldap_sync.c
+++ b/libraries/libldap/ldap_sync.c
@@ -64,11 +64,10 @@ ldap_sync_initialize( ldap_sync_t *ls_in )D%D
 		if ( ls == NULL ) {
 			return NULL;
 		}
-
-	} else {
-		memset( ls, 0, sizeof( ldap_sync_t ) );
 	}
 
+    memset( ls, 0, sizeof( ldap_sync_t ) );
+
 	ls->ls_scope = LDAP_SCOPE_SUBTREE;
 	ls->ls_timeout = -1;
 
-- 
1.9.1

The attached patch file is derived from OpenLDAP Software. All of the
modifications to OpenLDAP Software represented in the following patch(es) were
developed by Alexey Kireyev alexey@kireyev.name. I have not assigned rights
and/or interest in this work to any party.
I, Alexey Kireyev, hereby place the following modifications to OpenLDAP Software
(and only these modifications) into the public domain. Hence, these
modifications may be freely used and/or redistributed for any purpose with or
without attribution and/or other notice.
Comment 1 Howard Chu 2014-12-10 22:59:13 UTC
alexey@kireyev.name wrote:
> Full_Name: Alexey Kireyev
> Version: 2.4.40
> OS: Ubuntu 14.04
> URL: ftp://ftp.openldap.org/incoming/
> Submission from: (NULL) (98.118.88.65)
>
>
> If not all fields in ldap_sync_t manually set after ldap_sync_initialize, then
> any following calls might (and most  probably will) ends in segmentation fault.
>
> Reason: ldap_sync_initialize doesn't zeroed newly allocated structure (it does
> it for pre-existing, though, which is wrong by itself in my view)

Thanks, you're right. fixed in master.
>
>
>
>
> --------------------------------------------------------------------------------------------------------
>
>
>>From 01149a2eba9f463261d88e5a1ce43e19c4a323cf Mon Sep 17 00:00:00 2001
> From: Alexey Kireyev <alexey@kireyev.name>
> Date: Wed, 10 Dec 2014 14:37:16 -0500
> Subject: [PATCH] Newly allocated ldap_sync_t has to be zero out
>
> ---
>   libraries/libldap/ldap_sync.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/libraries/libldap/ldap_sync.c b/libraries/libldap/ldap_sync.c
> index e573c3b..e79153f 100644
> --- a/libraries/libldap/ldap_sync.c
> +++ b/libraries/libldap/ldap_sync.c
> @@ -64,11 +64,10 @@ ldap_sync_initialize( ldap_sync_t *ls_in )D%D
>   		if ( ls == NULL ) {
>   			return NULL;
>   		}
> -
> -	} else {
> -		memset( ls, 0, sizeof( ldap_sync_t ) );
>   	}
>
> +    memset( ls, 0, sizeof( ldap_sync_t ) );
> +
>   	ls->ls_scope = LDAP_SCOPE_SUBTREE;
>   	ls->ls_timeout = -1;
>
>


-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/

Comment 2 Howard Chu 2014-12-10 23:00:22 UTC
changed notes
changed state Open to Test
moved from Incoming to Software Bugs
Comment 3 Quanah Gibson-Mount 2014-12-11 00:38:55 UTC
changed notes
changed state Test to Release
Comment 4 OpenLDAP project 2015-07-02 17:45:57 UTC
fixed in master
fixed in RE25
fixed in RE24
Comment 5 Quanah Gibson-Mount 2015-07-02 17:45:57 UTC
changed notes
changed state Release to Closed