summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2012-09-10 16:07:37 -0700
committerKarolin Seeger <kseeger@samba.org>2012-09-21 09:44:44 +0200
commitf919d070b1dc9c210e9b402806372fd2f041b35a (patch)
tree0f258878ea0da193dbef307144af99d305f27150
parent3709ac83a0671fc8ac546031f4992165a886de0d (diff)
downloadsamba-f919d070b1dc9c210e9b402806372fd2f041b35a.tar.gz
Fix bug #9147 - winbind can't fetch user or group info from AD via LDAP
Don't use "isprint" in ldb_binary_encode(). This is locale specific. Restrict to ASCII only, hex encode everything else. (cherry picked from commit 9258a7b9cfd5fb85e5361d1b49c3bb8655e97159)
-rw-r--r--source3/lib/ldb/common/ldb_parse.c11
-rw-r--r--source4/lib/ldb/common/ldb_parse.c11
2 files changed, 18 insertions, 4 deletions
diff --git a/source3/lib/ldb/common/ldb_parse.c b/source3/lib/ldb/common/ldb_parse.c
index bcc92c5b5c3..1412d5746c6 100644
--- a/source3/lib/ldb/common/ldb_parse.c
+++ b/source3/lib/ldb/common/ldb_parse.c
@@ -92,6 +92,13 @@ struct ldb_val ldb_binary_decode(void *mem_ctx, const char *str)
return ret;
}
+static bool need_encode(unsigned char cval)
+{
+ if (cval < 0x20 || cval > 0x7E || strchr(" *()\\&|!\"", cval)) {
+ return true;
+ }
+ return false;
+}
/*
encode a blob as a RFC2254 binary string, escaping any
@@ -105,7 +112,7 @@ char *ldb_binary_encode(void *mem_ctx, struct ldb_val val)
unsigned char *buf = val.data;
for (i=0;i<val.length;i++) {
- if (!isprint(buf[i]) || strchr(" *()\\&|!\"", buf[i])) {
+ if (need_encode(buf[i])) {
len += 2;
}
}
@@ -114,7 +121,7 @@ char *ldb_binary_encode(void *mem_ctx, struct ldb_val val)
len = 0;
for (i=0;i<val.length;i++) {
- if (!isprint(buf[i]) || strchr(" *()\\&|!\"", buf[i])) {
+ if (need_encode(buf[i])) {
snprintf(ret+len, 4, "\\%02X", buf[i]);
len += 3;
} else {
diff --git a/source4/lib/ldb/common/ldb_parse.c b/source4/lib/ldb/common/ldb_parse.c
index ba16b57da3f..22a25c9b814 100644
--- a/source4/lib/ldb/common/ldb_parse.c
+++ b/source4/lib/ldb/common/ldb_parse.c
@@ -89,6 +89,13 @@ struct ldb_val ldb_binary_decode(void *mem_ctx, const char *str)
return ret;
}
+static bool need_encode(unsigned char cval)
+{
+ if (cval < 0x20 || cval > 0x7E || strchr(" *()\\&|!\"", cval)) {
+ return true;
+ }
+ return false;
+}
/*
encode a blob as a RFC2254 binary string, escaping any
@@ -102,7 +109,7 @@ char *ldb_binary_encode(void *mem_ctx, struct ldb_val val)
unsigned char *buf = val.data;
for (i=0;i<val.length;i++) {
- if (!isprint(buf[i]) || strchr(" *()\\&|!\"", buf[i])) {
+ if (need_encode(buf[i])) {
len += 2;
}
}
@@ -111,7 +118,7 @@ char *ldb_binary_encode(void *mem_ctx, struct ldb_val val)
len = 0;
for (i=0;i<val.length;i++) {
- if (!isprint(buf[i]) || strchr(" *()\\&|!\"", buf[i])) {
+ if (need_encode(buf[i])) {
snprintf(ret+len, 4, "\\%02X", buf[i]);
len += 3;
} else {