diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2011-03-04 22:17:55 +0100 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2011-04-08 11:32:23 -0400 |
commit | 4a28fb10122bd74ba33607af46f028813de9161d (patch) | |
tree | ac0e97fc7be4f8c84a8591acc3fc66e96366aa8e /src/util | |
parent | 63d85fff72563cb913287ab7785c551fa98fc35d (diff) | |
download | sssd-4a28fb10122bd74ba33607af46f028813de9161d.tar.gz sssd-4a28fb10122bd74ba33607af46f028813de9161d.tar.bz2 sssd-4a28fb10122bd74ba33607af46f028813de9161d.zip |
Don't pass NULL to printf for TLS errors
https://fedorahosted.org/sssd/ticket/643
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/sss_ldap.c | 18 | ||||
-rw-r--r-- | src/util/sss_ldap.h | 15 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/util/sss_ldap.c b/src/util/sss_ldap.c index f098e7d6..a4d73a8a 100644 --- a/src/util/sss_ldap.c +++ b/src/util/sss_ldap.c @@ -22,7 +22,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 14747dff..223f6ecd 100644 --- a/src/util/sss_ldap.h +++ b/src/util/sss_ldap.h @@ -22,6 +22,21 @@ #define __SSS_LDAP_H__ #include <ldap.h> +#include <talloc.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, |