From f2c39d4869da56268726f6e8fc224de8cecb7336 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Oct 15 2012 15:59:11 +0000 Subject: LDAP: Check validity of naming_context https://fedorahosted.org/sssd/ticket/1581 If the namingContext attribute had no values or multiple values, then our code would dereference a NULL pointer. --- diff --git a/src/providers/ldap/sdap.c b/src/providers/ldap/sdap.c index cdc8b1f..f5b1f95 100644 --- a/src/providers/ldap/sdap.c +++ b/src/providers/ldap/sdap.c @@ -746,7 +746,7 @@ static char *get_naming_context(TALLOC_CTX *mem_ctx, * a zero-length namingContexts value in some situations. In this * case, we should return it as NULL so things fail gracefully. */ - if (naming_context[0] == '\0') { + if (naming_context && naming_context[0] == '\0') { talloc_zfree(naming_context); }