From 4a28fb10122bd74ba33607af46f028813de9161d Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 4 Mar 2011 22:17:55 +0100 Subject: Don't pass NULL to printf for TLS errors https://fedorahosted.org/sssd/ticket/643 --- src/util/sss_ldap.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/util/sss_ldap.c') diff --git a/src/util/sss_ldap.c b/src/util/sss_ldap.c index f098e7d6d..a4d73a8aa 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, -- cgit