From: Andrew Date: Mon, 5 Jan 2026 18:00:20 +0000 (+0000) Subject: ldap: fix `Curl_ldap_version()` for IBMi/OS400 X-Git-Tag: curl-8_18_0~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0343951cb5cf8b10699805ab7e64012b55dd5657;p=thirdparty%2Fcurl.git ldap: fix `Curl_ldap_version()` for IBMi/OS400 - `LDAP_OPT_SUCCESS` (== 0) is missing from some LDAP implementations and documented to use `LDAP_SUCCESS` (== 0) instead. Use literal zero to avoid macro name differences. - fix freeing `LDAP_OPT_API_INFO` buffers: - docs suggest `ldapai_vendor_name` on IBMi is `const char *`. Nothing in docs says it need to be freed. - `ldapai_extensions` need to be freed, according to docs. However, on IBMi there is `ldap_value_free()` function for it. Ref: https://www.ibm.com/docs/en/svd/10.0.3?topic=settings-ldap-opt-api-info Fixing, on OS400 (V7R4M0): ``` CZM1003: LDAP__819.c, 1028.56: CZM0045(30) Undeclared identifier LDAP_OPT_SUCCESS. CZM1003: LDAP__819.c, 1036.21: CZM0280(30) Function argument assignment between types "char*" and "const char*" is not allowed. CZM1001: LDAP__819.c, 1037.5: CZM0304(10) No function prototype given for "ber_memvfree". ... CZS0601: Module LDAP is not created because statement errors occurred. ``` Follow-up to 859ce48de12986f5bf846c2800dacab893ff12c1 #19832 Fixes #20188 Closes #20189 --- diff --git a/lib/ldap.c b/lib/ldap.c index 71871fc742..55f39e147c 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -1022,7 +1022,9 @@ void Curl_ldap_version(char *buf, size_t bufsz) LDAPAPIInfo api; api.ldapai_info_version = LDAP_API_INFO_VERSION; - if(ldap_get_option(NULL, LDAP_OPT_API_INFO, &api) == LDAP_OPT_SUCCESS) { + /* Comparing against 0, as different platforms + disagree on the success define name */ + if(ldap_get_option(NULL, LDAP_OPT_API_INFO, &api) == 0) { unsigned int patch = (unsigned int)(api.ldapai_vendor_version % 100); unsigned int major = (unsigned int)(api.ldapai_vendor_version / 10000); unsigned int minor = @@ -1030,8 +1032,12 @@ void Curl_ldap_version(char *buf, size_t bufsz) - patch) / 100; curl_msnprintf(buf, bufsz, "%s/%u.%u.%u%s", api.ldapai_vendor_name, major, minor, patch, flavor); +#ifdef __OS400__ + ldap_value_free(api.ldapai_extensions); +#else ldap_memfree(api.ldapai_vendor_name); ber_memvfree((void **)api.ldapai_extensions); +#endif } else curl_msnprintf(buf, bufsz, "LDAP/1");