Skip to content

Commit 116d622

Browse files
thalmanalexey-tikhonov
authored andcommitted
Enumerate object with escaped characters in name
This patch fixes enumeration when DN in LDAP server contains special characters. The libldb expects that '\' is followed by two hex digits in filter. Strings like '\#' must be sanitized into '\5c#' before they are used for searching. Resolves: #7876 Reviewed-by: Alejandro López <[email protected]> Reviewed-by: Dan Lavu <[email protected]> (cherry picked from commit 158b4cd) Reviewed-by: Alejandro López <[email protected]>
1 parent 53365dc commit 116d622

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/db/sysdb_search.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ static errno_t sysdb_enum_dn_filter(TALLOC_CTX *mem_ctx,
814814
{
815815
TALLOC_CTX *tmp_ctx = NULL;
816816
char *dn_filter;
817+
char *sanitized_dn;
817818
const char *fqname;
818819
errno_t ret;
819820

@@ -844,11 +845,18 @@ static errno_t sysdb_enum_dn_filter(TALLOC_CTX *mem_ctx,
844845
}
845846

846847
for (size_t i = 0; i < ts_res->count; i++) {
848+
ret = sss_filter_sanitize_dn(tmp_ctx,
849+
ldb_dn_get_linearized(ts_res->msgs[i]->dn),
850+
&sanitized_dn);
851+
if (ret != EOK) {
852+
goto done;
853+
}
847854
dn_filter = talloc_asprintf_append(
848855
dn_filter,
849856
"(%s=%s)",
850857
SYSDB_DN,
851-
ldb_dn_get_linearized(ts_res->msgs[i]->dn));
858+
sanitized_dn);
859+
talloc_free(sanitized_dn);
852860
if (dn_filter == NULL) {
853861
ret = ENOMEM;
854862
goto done;

0 commit comments

Comments
 (0)