Skip to content

Commit

Permalink
EscapeLDAPValue - catch trailing escape character (#13452)
Browse files Browse the repository at this point in the history
* [VAULT-4018] - EscapeLDAPValue catch trailing escape character
  • Loading branch information
VinnyHC committed Dec 15, 2021
1 parent 8bcf5c9 commit eadbe96
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelog/13452.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
sdk/helper/ldaputil: properly escape a trailing escape character to prevent panics.
```
2 changes: 1 addition & 1 deletion sdk/helper/ldaputil/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions sdk/helper/ldaputil/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit eadbe96

Please sign in to comment.