Example:
package main
import "github.com/go-ldap/ldap"
func main() {
ldap.CompileFilter("((cn=)")
}
When running the example, it fails to parse the filter and crashes while logging the error message:
panic: runtime error: slice bounds out of range
goroutine 1 [running]:
panic(0x54ef60, 0xc82000a0e0)
/usr/lib/golang/src/runtime/panic.go:481 +0x3e6
github.com/go-ldap/ldap.CompileFilter(0x57d790, 0x6, 0xc820014810, 0x0, 0x0)
/root/src/github.com/go-ldap/ldap/filter.go:86 +0x41e
main.main()
/root/test/test.go:6 +0x2c
The problem is with this line in ldap/filter.go, pos gets invalid value:
return nil, NewError(ErrorFilterCompile, errors.New("ldap: finished compiling filter with extra at end: "+fmt.Sprint(filter[pos:])))