Skip to content
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

[VAULT-4018] EscapeLDAPValue - catch trailing escape character #13452

Merged
merged 2 commits into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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\\\\",
VinnyHC marked this conversation as resolved.
Show resolved Hide resolved
"test\\ ": "test\\\\\\ ",
}

for test, answer := range testcases {
Expand Down