mirror of
https://github.com/curl/curl.git
synced 2026-07-24 14:27:16 +03:00
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 859ce48de1 #19832
Fixes #20188
Closes #20189
This commit is contained in:
parent
0ec07e38f3
commit
0343951cb5
1 changed files with 7 additions and 1 deletions
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue