Skip to content
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

fix dn parsing without attr or value #119

Merged
merged 2 commits into from
Jun 27, 2017
Merged

Conversation

vetinari
Copy link
Contributor

fixes #114

@liggitt
Copy link
Contributor

liggitt commented Jun 26, 2017

LGTM, squash before merge

@vetinari
Copy link
Contributor Author

@liggitt done

@@ -143,6 +143,9 @@ func ParseDN(str string) (*DN, error) {
}
} else if char == ',' || char == '+' {
// We're done with this RDN or value, push it
if len(attribute.Type) == 0 {
return nil, errors.New("incomplete type, value pair")
Copy link
Contributor

@liggitt liggitt Jun 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just had a thought... should we include stringFromBuffer() in the error to aid debugging the bad attribute? or if we don't want to allow injecting arbitrary values into the message, at least include the position?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we didn't include the bad attribute in the "DN ended with incomplete type, value pair" message

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we also need to check for len(attribute.Type) == 0 in the if char == '=' block, to catch =foo,DC=example,DC=com?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's caught here or with the "DN ended with incomplete type, value pair" error, adding
"=test,DC=example,DC=com": "incomplete type, value pair", in dn_test.go:TestErrorDNParsing() passes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added as test and squashed

@liggitt
Copy link
Contributor

liggitt commented Jun 27, 2017

thanks, looks like it needs a rebase on top of your other PR

@vetinari
Copy link
Contributor Author

done...

@liggitt liggitt merged commit 37f35d7 into go-ldap:master Jun 27, 2017
@vetinari vetinari deleted the parse-dn-fix branch June 27, 2017 06:51
hspak added a commit to ripple/ldap that referenced this pull request Jul 28, 2017
* upstream/master:
  fix dn parsing without attr or value (go-ldap#119)
  fix unbalanced parenthesis panic when compiling filter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem with ParseDN
2 participants