summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-05-12 08:26:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:16:40 -0500
commitc956f4f98205c376062c4d634fd4ba4fb41031e4 (patch)
tree88b53e6c8bf0cd97e0dee6dcad52a7145567bb94 /source4/libcli
parentea6943ec79729800c520daed8d4128f1d4530a93 (diff)
downloadsamba-c956f4f98205c376062c4d634fd4ba4fb41031e4.tar.gz
samba-c956f4f98205c376062c4d634fd4ba4fb41031e4.tar.bz2
samba-c956f4f98205c376062c4d634fd4ba4fb41031e4.zip
r6745: - escape spaces in binary ldap blobs
- expose the ldap filter string parsing outside of ldap.c (This used to be commit b644ff6fe164fbe359c47e4d34f5ad490ff61d5b)
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/ldap/ldap.c16
-rw-r--r--source4/libcli/ldap/ldap.h2
2 files changed, 15 insertions, 3 deletions
diff --git a/source4/libcli/ldap/ldap.c b/source4/libcli/ldap/ldap.c
index 1a4f323ebf..9a8a7bb589 100644
--- a/source4/libcli/ldap/ldap.c
+++ b/source4/libcli/ldap/ldap.c
@@ -150,7 +150,7 @@ static const char *ldap_binary_encode(TALLOC_CTX *mem_ctx, DATA_BLOB blob)
char *ret;
int len = blob.length;
for (i=0;i<blob.length;i++) {
- if (!isprint(blob.data[i]) || blob.data[i] == '\\') {
+ if (!isprint(blob.data[i]) || strchr(" *()\\&|!", blob.data[i])) {
len += 2;
}
}
@@ -159,7 +159,7 @@ static const char *ldap_binary_encode(TALLOC_CTX *mem_ctx, DATA_BLOB blob)
len = 0;
for (i=0;i<blob.length;i++) {
- if (!isprint(blob.data[i]) || blob.data[i] == '\\') {
+ if (!isprint(blob.data[i]) || strchr(" *()\\&|!", blob.data[i])) {
snprintf(ret+len, 4, "\\%02X", blob.data[i]);
len += 3;
} else {
@@ -318,7 +318,7 @@ static struct ldap_parse_tree *ldap_parse_filtercomp(TALLOC_CTX *mem_ctx,
<filter> ::= '(' <filtercomp> ')'
*/
static struct ldap_parse_tree *ldap_parse_filter(TALLOC_CTX *mem_ctx,
- const char **s)
+ const char **s)
{
char *l, *s2;
const char *p, *p2;
@@ -1335,3 +1335,13 @@ BOOL ldap_parse_basic_url(TALLOC_CTX *mem_ctx, const char *url,
}
+
+/*
+ externally callable version of filter string parsing - used in the
+ cldap server
+*/
+struct ldap_parse_tree *ldap_parse_filter_string(TALLOC_CTX *mem_ctx,
+ const char *s)
+{
+ return ldap_parse_filter(mem_ctx, &s);
+}
diff --git a/source4/libcli/ldap/ldap.h b/source4/libcli/ldap/ldap.h
index 50031fd60c..63d79628a9 100644
--- a/source4/libcli/ldap/ldap.h
+++ b/source4/libcli/ldap/ldap.h
@@ -323,6 +323,8 @@ BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result);
BOOL ldap_decode(struct asn1_data *data, struct ldap_message *msg);
BOOL ldap_parse_basic_url(TALLOC_CTX *mem_ctx, const char *url,
char **host, uint16_t *port, BOOL *ldaps);
+struct ldap_parse_tree *ldap_parse_filter_string(TALLOC_CTX *mem_ctx,
+ const char *s);
/* The following definitions come from libcli/ldap/ldap_client.c */