summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2021-01-04 13:55:01 +0100
committerJeremy Allison <jra@samba.org>2021-01-08 20:31:33 +0000
commitb6a57c49c00a778f954aaf10db6ebe6dca8f5ae2 (patch)
tree1322b5695981dee221e31a6b14243529cada9206 /lib
parentfd056127944182bf1fa96d025a4418d9c05d1982 (diff)
downloadsamba-b6a57c49c00a778f954aaf10db6ebe6dca8f5ae2.tar.gz
ldb: Use hex_byte() in ldb_binary_decode()
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/ldb/common/ldb_parse.c27
1 files changed, 4 insertions, 23 deletions
diff --git a/lib/ldb/common/ldb_parse.c b/lib/ldb/common/ldb_parse.c
index 7e15206b168..f0045ad2093 100644
--- a/lib/ldb/common/ldb_parse.c
+++ b/lib/ldb/common/ldb_parse.c
@@ -53,26 +53,6 @@
*/
#define LDB_MAX_PARSE_TREE_DEPTH 128
-static int ldb_parse_hex2char(const char *x)
-{
- if (isxdigit(x[0]) && isxdigit(x[1])) {
- const char h1 = x[0], h2 = x[1];
- int c = 0;
-
- if (h1 >= 'a') c = h1 - (int)'a' + 10;
- else if (h1 >= 'A') c = h1 - (int)'A' + 10;
- else if (h1 >= '0') c = h1 - (int)'0';
- c = c << 4;
- if (h2 >= 'a') c += h2 - (int)'a' + 10;
- else if (h2 >= 'A') c += h2 - (int)'A' + 10;
- else if (h2 >= '0') c += h2 - (int)'0';
-
- return c;
- }
-
- return -1;
-}
-
/*
a filter is defined by:
<filter> ::= '(' <filtercomp> ')'
@@ -101,10 +81,11 @@ struct ldb_val ldb_binary_decode(TALLOC_CTX *mem_ctx, const char *str)
for (i=j=0;i<slen;i++) {
if (str[i] == '\\') {
- int c;
+ uint8_t c;
+ bool ok;
- c = ldb_parse_hex2char(&str[i+1]);
- if (c == -1) {
+ ok = hex_byte(&str[i+1], &c);
+ if (!ok) {
talloc_free(ret.data);
memset(&ret, 0, sizeof(ret));
return ret;