From 2f8fbe268280629f98cafdd431002ca61d484169 Mon Sep 17 00:00:00 2001 From: Thierry Bordaz Date: Feb 14 2020 14:44:38 +0000 Subject: Ticket 50898 - ldclt core dumped when run with -e genldif option Bug Description: ldctl can generate ldif file. If the template file or option -e (person/InetOrgPerson/emailPerson) is missing, then the attribute value is not set. When dereferencing attribute.mod_values it crashes Fix Description: Test that attribute.mod_values is set. If it is not (tha means the objectclass value was not provided) and return an error https://pagure.io/389-ds-base/issue/50898 Reviewed by: ? Platforms tested: F29 Flag Day: no Doc impact: no --- diff --git a/ldap/servers/slapd/tools/ldclt/ldapfct.c b/ldap/servers/slapd/tools/ldclt/ldapfct.c index dbfc553..8ed83cc 100644 --- a/ldap/servers/slapd/tools/ldclt/ldapfct.c +++ b/ldap/servers/slapd/tools/ldclt/ldapfct.c @@ -1529,12 +1529,18 @@ buildNewEntry( nbAttribs = 0; /* No attributes yet */ attribute.mod_op = LDAP_MOD_ADD; attribute.mod_type = "objectclass"; + attribute.mod_values = NULL; if (mctx.mode & OC_PERSON) attribute.mod_values = strList1("person"); if (mctx.mode & OC_EMAILPERSON) attribute.mod_values = strList1("emailPerson"); if (mctx.mode & OC_INETORGPRSON) /*JLS 07-11-00*/ attribute.mod_values = strList1("inetOrgPerson"); /*JLS 07-11-00*/ + if (attribute.mod_values == NULL) { + printf("ldclt[%d]: T%03d: attribute objectclass not defined (supported values are person/emailPerson/inetOrgPerson)\n", + mctx.pid, tttctx->thrdNum); + return -1; + } if (addAttrib(attrs, nbAttribs++, &attribute) < 0) return (-1);