You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While I cannot provide the original packets that triggered this initially I have been able to reproduce this panic and one other using a modified version of the existing TestGetLDAPError test for GetLDAPError.
Reproducer for interface conversion: interface {} is nil, not string at error.go:216
package main
import (
"fmt"
ber "github.com/go-asn1-ber/asn1-ber"
ldap "github.com/go-ldap/ldap/v3"
)
funcmain() {
bindResponse:=ber.Encode(ber.ClassApplication, ber.TypeConstructed, ldap.ApplicationBindResponse, nil, "Bind Response")
bindResponse.AppendChild(ber.Encode(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, int64(ldap.LDAPResultInvalidCredentials), "resultCode"))
bindResponse.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, "dc=example,dc=org", "matchedDN"))
// Original message included the line below// bindResponse.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, diagnosticMessage, "diagnosticMessage"))bindResponse.AppendChild(ber.Encode(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, nil, "diagnosticMessage"))
packet:=ber.NewSequence("LDAPMessage")
packet.AppendChild(ber.Encode(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, int64(0), "messageID"))
packet.AppendChild(bindResponse)
fmt.Printf("packet: %+v\n", packet)
_=ldap.GetLDAPError(packet)
}
Results
go run main.go
packet: &{Identifier:{ClassType:0 TagType:32 Tag:16} Value:<nil> ByteValue:[] Data:adc=example,dc=org Children:[0x140000ee2a0 0x140000ee070] Description:LDAPMessage}
panic: interface conversion: interface {} is nil, not string
goroutine 1 [running]:
github.com/go-ldap/ldap/v3.GetLDAPError(0x140000ee230)
/Users/tom.sellers/go/pkg/mod/github.com/go-ldap/ldap/[email protected]/error.go:216 +0x380
main.main()
/Users/tom.sellers/Downloads/ldap-testing/main.go:24 +0x19c
exit status 2
Reproducer for interface conversion: interface {} is string, not int64 at error.go:209
package main
import (
ber "github.com/go-asn1-ber/asn1-ber"
ldap "github.com/go-ldap/ldap/v3"
)
funcmain() {
diagnosticMessage:="Detailed error message"bindResponse:=ber.Encode(ber.ClassApplication, ber.TypeConstructed, ldap.ApplicationBindResponse, nil, "Bind Response")
bindResponse.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, "dc=example,dc=org", "matchedDN"))
bindResponse.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, diagnosticMessage, "diagnosticMessage"))
// The following was originally the first call to bindResponse.AppendChild()bindResponse.AppendChild(ber.Encode(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, int64(ldap.LDAPResultInvalidCredentials), "resultCode"))
packet:=ber.NewSequence("LDAPMessage")
packet.AppendChild(ber.Encode(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, int64(0), "messageID"))
packet.AppendChild(bindResponse)
_=ldap.GetLDAPError(packet)
}
Results
go run main.go
panic: interface conversion: interface {} is string, not int64
goroutine 1 [running]:
github.com/go-ldap/ldap/v3.GetLDAPError(0x1400011c230)
/Users/tom.sellers/go/pkg/mod/github.com/go-ldap/ldap/[email protected]/error.go:209 +0x3a0
main.main()
/Users/tom.sellers/Downloads/ldap-testing/main.go:21 +0x158
exit status 2
GetLDAPError
has been observed to panic when callingSimpleBind
against certain targets.While I cannot provide the original packets that triggered this initially I have been able to reproduce this panic and one other using a modified version of the existing
TestGetLDAPError
test forGetLDAPError
.Reproducer for
interface conversion: interface {} is nil, not string
aterror.go:216
Results
Related code
ldap/error.go
Lines 213 to 217 in 3646355
Reproducer for
interface conversion: interface {} is string, not int64
aterror.go:209
Results
Related code
ldap/error.go
Lines 208 to 209 in 3646355
The text was updated successfully, but these errors were encountered: