diff options
author | bubulle <bubulle@alioth.debian.org> | 2012-10-30 06:15:57 +0000 |
---|---|---|
committer | bubulle <bubulle@alioth.debian.org> | 2012-10-30 06:15:57 +0000 |
commit | 2cf876031f5616a1de04777c978d7847887b45ac (patch) | |
tree | c5926c67d2e01d5e3145f4657d1ee37ea70146a0 /source4/lib/ldb | |
parent | 12dc539c4df1b4e4282f22c5691ca8e3a0989f24 (diff) | |
download | samba-2cf876031f5616a1de04777c978d7847887b45ac.tar.gz |
Load samba-3.6.9 into branches/samba/upstream.upstream/3.6.9
git-svn-id: svn://svn.debian.org/svn/pkg-samba/branches/samba/upstream@4174 fc4039ab-9d04-0410-8cac-899223bdd6b0
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r-- | source4/lib/ldb/common/ldb_parse.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/source4/lib/ldb/common/ldb_parse.c b/source4/lib/ldb/common/ldb_parse.c index b4eabf8375..1ea425a89c 100644 --- a/source4/lib/ldb/common/ldb_parse.c +++ b/source4/lib/ldb/common/ldb_parse.c @@ -111,6 +111,13 @@ struct ldb_val ldb_binary_decode(TALLOC_CTX *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 @@ -124,7 +131,7 @@ char *ldb_binary_encode(TALLOC_CTX *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; } } @@ -133,7 +140,7 @@ char *ldb_binary_encode(TALLOC_CTX *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 { |