diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2011-03-04 22:17:55 +0100 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2011-06-30 14:07:38 -0400 |
commit | b6ed1d6569fea94cb58d91877c1873ec28328fd7 (patch) | |
tree | 3b56e12e1a46a883f43cdfb0ed2b9ad42fccdb48 /src/util | |
parent | 177c89d1c8a4a8a5201c957dbe9d04fa95e00d51 (diff) | |
download | sssd-b6ed1d6569fea94cb58d91877c1873ec28328fd7.tar.gz sssd-b6ed1d6569fea94cb58d91877c1873ec28328fd7.tar.xz sssd-b6ed1d6569fea94cb58d91877c1873ec28328fd7.zip |
Don't pass NULL to printf for TLS errors
https://fedorahosted.org/sssd/ticket/643
Conflicts:
src/util/sss_ldap.h
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/sss_ldap.c | 18 | ||||
-rw-r--r-- | src/util/sss_ldap.h | 14 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/util/sss_ldap.c b/src/util/sss_ldap.c index e4764d98d..9f76870f8 100644 --- a/src/util/sss_ldap.c +++ b/src/util/sss_ldap.c @@ -28,7 +28,25 @@ #include "config.h" #include "util/sss_ldap.h" +#include "util/util.h" +int sss_ldap_get_diagnostic_msg(TALLOC_CTX *mem_ctx, LDAP *ld, char **_errmsg) +{ + char *errmsg = NULL; + int optret; + + optret = ldap_get_option(ld, SDAP_DIAGNOSTIC_MESSAGE, (void*)&errmsg); + if (optret != LDAP_SUCCESS) { + return EINVAL; + } + + *_errmsg = talloc_strdup(mem_ctx, errmsg ? errmsg : "unknown error"); + ldap_memfree(errmsg); + if (*_errmsg == NULL) { + return ENOMEM; + } + return EOK; +} int sss_ldap_control_create(const char *oid, int iscritical, struct berval *value, int dupval, diff --git a/src/util/sss_ldap.h b/src/util/sss_ldap.h index 2643e82fc..df96b9dcb 100644 --- a/src/util/sss_ldap.h +++ b/src/util/sss_ldap.h @@ -27,6 +27,20 @@ #include <talloc.h> #include <tevent.h> +#ifdef LDAP_OPT_DIAGNOSTIC_MESSAGE +#define SDAP_DIAGNOSTIC_MESSAGE LDAP_OPT_DIAGNOSTIC_MESSAGE +#else +#ifdef LDAP_OPT_ERROR_STRING +#define SDAP_DIAGNOSTIC_MESSAGE LDAP_OPT_ERROR_STRING +#else +#error No extended diagnostic message available +#endif +#endif + +int sss_ldap_get_diagnostic_msg(TALLOC_CTX *mem_ctx, + LDAP *ld, + char **_errmsg); + int sss_ldap_control_create(const char *oid, int iscritical, struct berval *value, int dupval, LDAPControl **ctrlp); |