https://bugs.openldap.org/show_bug.cgi?id=9465
Issue ID: 9465 Summary: When compiled in debug mode ldap_get_option asserts breaking API compatibility Product: OpenLDAP Version: unspecified Hardware: All OS: All Status: UNCONFIRMED Severity: normal Priority: --- Component: libraries Assignee: bugs@openldap.org Reporter: doug.leavitt@oracle.com Target Milestone: ---
In a multi-threaded application, sometimes it is useful to use ldap_get_option to get the LDAP_OPT_RESULT_CODE of an operation (possibly from a different thread).
A useful side effect of calling ldap_get_option is that if the connection is no longer valid, the API returns LDAP_OPT_ERR when compiled without debug per the man page: ERRORS On success, the functions return LDAP_OPT_SUCCESS, while they may return LDAP_OPT_ERROR to indicate a generic option handling error. ...
However, if libldap is compiled with debugging enabled the same if test throws an assert instead of returning the documented error code, changing the behavior of the API.
Specifically this assert: https://git.openldap.org/openldap/openldap/-/blob/master/libraries/libldap/o...
Compiling in debugging is useful for tracing output even in complex production environments but since there is no specific libldap API to test for valid LD* the seemingly best choice of ldap_get_option breaks in this situation.
It is not clear what the original rational for the assert at this specific location was.
This ITS requests removing the assert so that ldap_get_option behaves the same both with and without debugging enabled.
https://bugs.openldap.org/show_bug.cgi?id=9465
Howard Chu hyc@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |TEST Status|UNCONFIRMED |RESOLVED
--- Comment #1 from Howard Chu hyc@openldap.org --- (In reply to doug.leavitt@oracle.com from comment #0)
In a multi-threaded application, sometimes it is useful to use ldap_get_option to get the LDAP_OPT_RESULT_CODE of an operation (possibly from a different thread).
A useful side effect of calling ldap_get_option is that if the connection is no longer valid, the API returns LDAP_OPT_ERR when compiled without debug per the man page: ERRORS On success, the functions return LDAP_OPT_SUCCESS, while they may return LDAP_OPT_ERROR to indicate a generic option handling error. ...
However, if libldap is compiled with debugging enabled the same if test throws an assert instead of returning the documented error code, changing the behavior of the API.
Specifically this assert: https://git.openldap.org/openldap/openldap/-/blob/master/libraries/libldap/ options.c#L113
Compiling in debugging is useful for tracing output even in complex production environments but since there is no specific libldap API to test for valid LD* the seemingly best choice of ldap_get_option breaks in this situation.
It is not clear what the original rational for the assert at this specific location was.
This ITS requests removing the assert so that ldap_get_option behaves the same both with and without debugging enabled.
Removed assert. While I agree it served no purpose here, not sure that the use case makes much sense. What makes the LDAP* handle invalid? If it's already freed, then accessing the handle is undefined behavior.
https://bugs.openldap.org/show_bug.cgi?id=9465
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |2.5.2
--- Comment #2 from Quanah Gibson-Mount quanah@openldap.org --- • 00a5815c by Howard Chu at 2021-02-11T17:03:32+00:00 ITS#9465 remove assert in ldap_get_option()
https://bugs.openldap.org/show_bug.cgi?id=9465
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Resolution|TEST |FIXED
https://bugs.openldap.org/show_bug.cgi?id=9465
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |VERIFIED