summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fd01cdd)
raw | patch | inline | side by side (parent: fd01cdd)
author | Marc Fournier <marc.fournier@camptocamp.com> | |
Wed, 28 Jun 2017 11:46:59 +0000 (13:46 +0200) | ||
committer | Marc Fournier <marc.fournier@camptocamp.com> | |
Wed, 28 Jun 2017 11:46:59 +0000 (13:46 +0200) |
This prevents collectd from segfaulting when the ldap session setup
fails before opening a connection to openldap (syntax error in the URL
option for example).
fails before opening a connection to openldap (syntax error in the URL
option for example).
src/openldap.c | patch | blob | history |
diff --git a/src/openldap.c b/src/openldap.c
index 61eb62e3577eb508e0dd613bfd92570d374e4b42..c060bdc037483cb8281cdddd93e91c347b819a48 100644 (file)
--- a/src/openldap.c
+++ b/src/openldap.c
if (rc != LDAP_SUCCESS) {
ERROR("openldap plugin: ldap_initialize failed: %s", ldap_err2string(rc));
st->state = 0;
- ldap_unbind_ext_s(ld, NULL, NULL);
+ if (ld != NULL)
+ ldap_unbind_ext_s(ld, NULL, NULL);
return (-1);
}
ERROR("openldap plugin: Failed to start tls on %s: %s", st->url,
ldap_err2string(rc));
st->state = 0;
- ldap_unbind_ext_s(st->ld, NULL, NULL);
+ if (st->ld != NULL)
+ ldap_unbind_ext_s(st->ld, NULL, NULL);
return (-1);
}
}
ERROR("openldap plugin: Failed to bind to %s: %s", st->url,
ldap_err2string(rc));
st->state = 0;
- ldap_unbind_ext_s(st->ld, NULL, NULL);
+ if (st->ld != NULL)
+ ldap_unbind_ext_s(st->ld, NULL, NULL);
return (-1);
} else {
DEBUG("openldap plugin: Successfully connected to %s", st->url);
ERROR("openldap plugin: Failed to execute search: %s", ldap_err2string(rc));
ldap_msgfree(result);
st->state = 0;
- ldap_unbind_ext_s(st->ld, NULL, NULL);
+ if (st->ld != NULL)
+ ldap_unbind_ext_s(st->ld, NULL, NULL);
return (-1);
}