New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LDAPFilter::Match throws std::runtime_error if a bundle contains a key that is a leading substring of another key #227

Closed
jeffdiclemente opened this Issue Aug 14, 2017 · 2 comments

Comments

Projects
2 participants
@jeffdiclemente
Contributor

jeffdiclemente commented Aug 14, 2017

Calling LDAPFilter::Match on a bundle that contains the keys:

"apple" : "granny smith" 
"applesauce" : "yum" 

throws a std::runtime_error when creating an instance of cppmicroservices::Properties because Properties::Find_unlocked only does a strncasecmp of key.size() between key and keys[i].

Properties::Find_unlocked should check that the sizes of the two strings are equal before reporting duplicate keys and any exceptions thrown by Properties should be swallowed by LDAPFilter::Match before returning false since Match isn't supposed to throw exceptions.

@jeffdiclemente jeffdiclemente added the bug label Aug 14, 2017

@ksubramz ksubramz self-assigned this Aug 15, 2017

@ksubramz

This comment has been minimized.

Show comment
Hide comment
@ksubramz

ksubramz Aug 16, 2017

Contributor

The way this bug manifests is worth documenting - it's dependent on

  • if a key is a leading substring of another key, and
  • the AnyMap iteration order in Properties constructor.. specifically the line:

for (auto& iter : p)
in Properties::Properties(const AnyMap& p)

Suppose the range-based iterator gives out the key apple first and applesauce next, there is no exception triggered. However, if the iterator gives out the key applesauce first and then the key apple, the Properties::Find_unlocked call in the constructor does a strncasecmp of the key in question apple and the first 5 characters of applesauce, which is apple and throws an exception because they are equal.

It turns out I can't reproduce the bug with the keys specified in the Issue, however I can reproduce the bug with different sets of keys i.e. hosed, hosedd, hose

Contributor

ksubramz commented Aug 16, 2017

The way this bug manifests is worth documenting - it's dependent on

  • if a key is a leading substring of another key, and
  • the AnyMap iteration order in Properties constructor.. specifically the line:

for (auto& iter : p)
in Properties::Properties(const AnyMap& p)

Suppose the range-based iterator gives out the key apple first and applesauce next, there is no exception triggered. However, if the iterator gives out the key applesauce first and then the key apple, the Properties::Find_unlocked call in the constructor does a strncasecmp of the key in question apple and the first 5 characters of applesauce, which is apple and throws an exception because they are equal.

It turns out I can't reproduce the bug with the keys specified in the Issue, however I can reproduce the bug with different sets of keys i.e. hosed, hosedd, hose

@karthikreddy09 karthikreddy09 added this to In Progress in Release 3.2 Aug 23, 2017

@ksubramz

This comment has been minimized.

Show comment
Hide comment
@ksubramz

ksubramz Aug 24, 2017

Contributor

Merged.

Contributor

ksubramz commented Aug 24, 2017

Merged.

@ksubramz ksubramz closed this Aug 24, 2017

@ksubramz ksubramz moved this from In Progress to Done in Release 3.2 Aug 25, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment