EscapeLDAPValue - catch trailing escape character (#13452)

* [VAULT-4018] - EscapeLDAPValue catch trailing escape character
This commit is contained in:
Vinny Mannello 2021-12-15 13:17:07 -08:00 committed by GitHub
parent 0bd6f5392c
commit 62ecf23c2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

3
changelog/13452.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
sdk/helper/ldaputil: properly escape a trailing escape character to prevent panics.
```

View File

@ -512,7 +512,7 @@ func EscapeLDAPValue(input string) string {
// - null
for i := 0; i < len(input); i++ {
escaped := false
if input[i] == '\\' {
if input[i] == '\\' && i+1 < len(input)-1 {
i++
escaped = true
}

View File

@ -32,6 +32,9 @@ func TestLDAPEscape(t *testing.T) {
"test\\hello": "test\\\\hello",
" test ": "\\ test \\ ",
"": "",
"\\test": "\\\\test",
"test\\": "test\\\\",
"test\\ ": "test\\\\\\ ",
}
for test, answer := range testcases {