Bug 45994 - uldap_connection_init SEGFAULT if apr_ldap lib cannot be loaded
Summary: uldap_connection_init SEGFAULT if apr_ldap lib cannot be loaded
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_ldap (show other bugs)
Version: 2.2.9
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
Keywords: PatchAvailable
Depends on:
Reported: 2008-10-12 18:01 UTC by till toenges
Modified: 2008-12-16 15:31 UTC (History)
1 user (show)

Patch to avoid SEGFAULT (533 bytes, patch)
2008-10-15 10:40 UTC, Dan Poirier
Details | Diff
Better patch (638 bytes, patch)
2008-10-16 12:00 UTC, Dan Poirier
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description till toenges 2008-10-12 18:01:26 UTC
On line 248 uldap_connection_init in modules/ldap/util_ldap.c returns result->rc. That fails if apr_ldap cannot be loaded, because result is still NULL then.
Comment 1 Dan Poirier 2008-10-15 10:40:47 UTC
Created attachment 22740 [details]
Patch to avoid SEGFAULT

This patch avoids the segmentation fault.  

The result is still a bit ugly ([Wed Oct 15 13:37:19 2008] [warn] [client] [32143] auth_ldap authenticate: user x authentication failed; URI /foo [LDAP: ldap initialization failed][Unknown (private extension) error]) - maybe there's a better error code to use here.  

But if the ldap module can't be loaded, things are in bad shape anyway.
Comment 2 Dan Poirier 2008-10-16 12:00:34 UTC
Created attachment 22746 [details]
Better patch

Here's a better patch.  Thanks to Paul Reder for pointing out another problem that was lurking.  This patch checks for result being NULL and handles it
immediately, which makes it clearer that we're handling the case properly than
it was with the previous logic where there were multiple branches trying to
cover all the cases.
Comment 3 Dan Poirier 2008-11-04 06:03:24 UTC
Can you try the patch and see if it solves the problem?

Comment 4 Paul J. Reder 2008-12-16 15:31:00 UTC
I've committed this patch and submitted it for backporting.