Skip to content

Segfault with multi-entry attributes #218

@tiran

Description

@tiran

LDAP supports multi-valued entries. In almost all common cases ldap_first_attribute / ldap_next_attribute return an attribute once. In very rare cases like FreeIPA's ipaAllowedToPerform;write_keys, an entry can appear more than once in the result. python-ldap accumulates the multi-entry attribute in a single list.

However the implementation has a reference counting bug. It uses PyDict_GetItem and treats the object as owned object. However PyDict_GetItem only returns a borrowed reference. Application code must either Py_INCREF the reference to own it or never Py_DECREF the result.

The bug was never noticed before, because our tests don't trigger this particular behavior with OpenLDAP server. Although I tried, I wasn't able to reproduce the issue with OpenLDAP. But 389-DS can return an attribute multiple times, which causes python-ldap to segfault. Under Python 2, it doesn't segfault but the list is garbage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy