Commit e517e314 authored by ale's avatar ale

Fix nil pointer deref when ldap.params.attrs is not defined

The correct code is also easier to read.
parent b9d0d3e2
Pipeline #5899 passed with stages
in 1 minute and 34 seconds
......@@ -189,14 +189,16 @@ func newLDAPServiceBackend(pool *ldaputil.ConnectionPool, params *ldapServicePar
// Merge in attributes from the default map if unset, and
// convert them to a list to pass to NewSearchRequest.
for attrDst, attrSrc := range defaultLDAPAttributeMap {
if _, ok := params.Attrs[attrDst]; !ok {
params.Attrs[attrDst] = attrSrc
}
attrs := make(map[string]string)
for k, v := range defaultLDAPAttributeMap {
attrs[k] = v
}
for k, v := range params.Attrs {
attrs[k] = v
}
var attrList []string
for _, attrSrc := range params.Attrs {
attrList = append(attrList, attrSrc)
for _, v := range attrs {
attrList = append(attrList, v)
}
return &ldapServiceBackend{
......@@ -205,7 +207,7 @@ func newLDAPServiceBackend(pool *ldaputil.ConnectionPool, params *ldapServicePar
filter: params.SearchFilter,
scope: scope,
attrList: attrList,
attrs: params.Attrs,
attrs: attrs,
}, nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment