-
Notifications
You must be signed in to change notification settings - Fork 372
fixed nil cast #217
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
fixed nil cast #217
Conversation
johnweldon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @draeron for finding this issue and proposing this change. While reviewing I found there was a deeper issue caused by a careless merge on my part previously.
If you'd like to revise your PR as I suggest, I can merge it - otherwise, I'll make the changes I describe in a separate PR.
| @@ -0,0 +1,5 @@ | |||
| module go-ldap | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm generally in favor of adding go.(mod|sum) to the project, but let's do it in a separate PR
| } | ||
| if len(packet.Children) == 3 { | ||
| return addControlDescriptions(packet.Children[2]) | ||
| if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a subtle issue here, partially introduced by PR #191 where the getLDAPResultCode function was replaced by GetLDAPError - the semantics changed subtly with this PR, and I missed the implications when I merged it.
Even if there is no error, the original intent of this function is to add Descriptions; I think this may be a more useful change:
diff --git ldap.go ldap.go
index d766667..831fa02 100644
--- ldap.go
+++ ldap.go
@@ -270,10 +270,13 @@ func addRequestDescriptions(packet *ber.Packet) error {
}
func addDefaultLDAPResponseDescriptions(packet *ber.Packet) error {
- err := GetLDAPError(packet)
- packet.Children[1].Children[0].Description = "Result Code (" + LDAPResultCodeMap[err.(*Error).ResultCode] + ")"
- packet.Children[1].Children[1].Description = "Matched DN (" + err.(*Error).MatchedDN + ")"
- packet.Children[1].Children[2].Description = "Error Message"
+ resultCode := uint16(LDAPResultSuccess)
+ if err := GetLDAPError(packet); err != nil {
+ resultCode = err.(*Error).ResultCode
+ packet.Children[1].Children[2].Description = "Error Message"
+ }
+ packet.Children[1].Children[0].Description = "Result Code (" + LDAPResultCodeMap[resultCode] + ")"
+ packet.Children[1].Children[1].Description = "Matched DN"
if len(packet.Children[1].Children) > 3 {
packet.Children[1].Children[3].Description = "Referral"
}
I may need to find a good way to back out the previous PR that skews the original intent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any news here? I'm affected by this too. I don't mind to make another PR trying to address it and other possible occurrences of this same problem (If I find them).
|
Feel free to make a new PR if this isn't resolved by other more recent changes. |
Fix for #216