https://bugs.openldap.org/show_bug.cgi?id=10371
Issue ID: 10371 Summary: tools don't print useful error codes Product: OpenLDAP Version: unspecified Hardware: All OS: All Status: UNCONFIRMED Keywords: needs_review Severity: normal Priority: --- Component: client tools Assignee: bugs@openldap.org Reporter: hyc@openldap.org Target Milestone: ---
In tools/common.c, if ldap_result() returns an error, this return value is used directly as an LDAP error code in the subsequent call to tool_perror(). That is incorrect; ldap_result() always returns -1 on errors. The actual return code must be retrieved using ldap_get_option(ld, LDAP_OPT_RESULT_CODE,...). So up till now the tools have never printed the actual error message that's relevant to whatever failure occurred.
Other applications appear to have copied this erroneous behavior. E.g., in investigating ITS#10370 I see that curl's code does the same thing.
https://bugs.openldap.org/show_bug.cgi?id=10371
Howard Chu hyc@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |IN_PROGRESS Ever confirmed|0 |1
--- Comment #1 from Howard Chu hyc@openldap.org --- https://git.openldap.org/openldap/openldap/-/merge_requests/782
These bits were last touched in 2005, commit 81b28fe3299f1e3e123bfbdaff53c7c1e6c6bbe7
https://bugs.openldap.org/show_bug.cgi?id=10371
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Assignee|bugs@openldap.org |hyc@openldap.org Keywords|needs_review | Target Milestone|--- |2.6.11
https://bugs.openldap.org/show_bug.cgi?id=10371
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |TEST Status|IN_PROGRESS |RESOLVED
--- Comment #2 from Quanah Gibson-Mount quanah@openldap.org --- main:
• 87b3f207 by Howard Chu at 2025-08-04T19:10:38+00:00 ITS#10371 clients: print actual error code when ldap_result fails
RE26:
• 4e1d9cb6 by Howard Chu at 2025-09-08T23:02:25+00:00 ITS#10371 clients: print actual error code when ldap_result fails
https://bugs.openldap.org/show_bug.cgi?id=10371
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Resolution|TEST |FIXED Status|RESOLVED |VERIFIED