Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 750622

Summary: Fix Coverity (11104) Resource leak: ids_sasl_user_to_entry (slapd/saslbind.c)
Product: [Retired] 389 Reporter: Noriko Hosoi <nhosoi>
Component: Security - SASLAssignee: Noriko Hosoi <nhosoi>
Status: CLOSED ERRATA QA Contact: Chandrasekar Kannan <ckannan>
Severity: high Docs Contact:
Priority: high    
Version: 1.2.10CC: amsharma, benl, jgalipea, msvoboda, nkinder, rmeggins
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
URL: https://vm-025.idm.lab.bos.redhat.com:8443/sourcebrowser.htm?projectId=10010#mergedDefectId=11104&defectInstanceId=12322822&fileInstanceId=57016953
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Previously, allocated memory was not correctly released in the underlying code for the SASL GSSAPI authentication method, when checking the Simple Authentication and Security Layer (SASL) identity mappings. This problem could cause memory leaks when processing SASL bind requests, which eventually caused the LDAP server to terminate unexpectedly with a segmentation fault. This update adds function calls that are needed to free allocated memory correctly. Memory leaks no longer occur and the LDAP server no longer crashes in this scenario.
Story Points: ---
Clone Of:
: 757898 (view as bug list) Environment:
Last Closed: 2012-01-10 20:55:55 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 743970, 752607, 757898    
Attachments:
Description Flags
git patch file (master) nhosoi: review?, rmeggins: review+

Description Noriko Hosoi 2011-11-01 19:25:19 UTC
Description of problem:
> sasl_map_domap allocates strings for "base" and "filter" in it; the
> caller ids_sasl_user_to_entry releases them only when the function 
> returns non-NULL regexmatch (matched), but even if the return value 
> is NULL (did not match), the strings are allocated.
> 
> Fix: underlying function sasl_map_check should free "base" and "filter"
> if mapping did not match.

Comment 1 Noriko Hosoi 2011-11-02 17:03:37 UTC
Created attachment 531391 [details]
git patch file (master)

Bug Description: sasl_map_domap allocates strings for "base" and
"filter" in it; the caller ids_sasl_user_to_entry releases them
only when the function returns non-0 regexmatch (matched), but
even if the return value is 0 (did not match), the strings are
allocated.
    
Fix Description: underlying function sasl_map_check frees "base"
and "filter" if mapping did not match.

Comment 2 Noriko Hosoi 2011-11-02 23:08:17 UTC
Reviewed by Rich (Thank you!!)

Pushed to master.

commit 6af5ece3ca029271f2b2180c24bad546e2d64c45
Author: Noriko Hosoi <nhosoi.redhat.com>
Date:   Tue Nov 1 16:03:57 2011 -0700

    Bug 750622 - Fix Coverity (11104) Resource leak:
                 ids_sasl_user_to_entry (slapd/saslbind.c)

$ git merge 6af5ece3ca029271f2b2180c24bad546e2d64c45
Updating c077173..6af5ece
Fast-forward
 ldap/servers/slapd/sasl_map.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

$ git push
Counting objects: 11, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 874 bytes, done.
Total 6 (delta 4), reused 0 (delta 0)
To ssh://git.fedorahosted.org/git/389/ds.git
   c077173..6af5ece  master -> master

Note: I bumped up the priority/severity high.

Comment 6 Amita Sharma 2011-12-08 12:04:07 UTC
Based on comment#5, marking the bug as VERIFIED.

Comment 7 errata-xmlrpc 2011-12-19 19:52:47 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2011-1835.html

Comment 8 Rich Megginson 2012-01-10 20:54:20 UTC
Upstream ticket:
https://fedorahosted.org/389/ticket/255

Comment 9 Miroslav Svoboda 2012-01-17 11:31:20 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Previously, allocated memory was not correctly released in the underlying code for the SASL GSSAPI authentication method, when checking the Simple Authentication and Security Layer (SASL) identity mappings. This problem could cause memory leaks when processing SASL bind requests, which eventually caused the LDAP server to terminate unexpectedly with a segmentation fault. This update adds function calls that are needed to free allocated memory correctly. Memory leaks no longer occur and the LDAP server no longer crashes in this scenario.