summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common
diff options
context:
space:
mode:
authorDerrell Lipman <derrell@samba.org>2005-06-09 14:50:32 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:17:53 -0500
commitee3f4b12d22459405372e1c72efe3079a052601d (patch)
tree7a86b841d35426fa047ee0e9397e243696bacd38 /source4/lib/ldb/common
parentc63c28f5bd46e4a03e1cdd12b78934c0b88635a8 (diff)
downloadsamba-ee3f4b12d22459405372e1c72efe3079a052601d.tar.gz
samba-ee3f4b12d22459405372e1c72efe3079a052601d.tar.bz2
samba-ee3f4b12d22459405372e1c72efe3079a052601d.zip
r7438: work in progress
(This used to be commit 2fc5343f0637ef3109b079dbc33d6cf4e58c8d5e)
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r--source4/lib/ldb/common/ldb_explode_dn.c66
1 files changed, 13 insertions, 53 deletions
diff --git a/source4/lib/ldb/common/ldb_explode_dn.c b/source4/lib/ldb/common/ldb_explode_dn.c
index d3f278c776..e3cd53d047 100644
--- a/source4/lib/ldb/common/ldb_explode_dn.c
+++ b/source4/lib/ldb/common/ldb_explode_dn.c
@@ -21,6 +21,7 @@
#include "includes.h"
#include "ldb/include/ldb.h"
+#include "ldb/include/ldb_private.h"
#include "ldb/include/ldb_explode_dn.h"
#define LDB_PARSE_DN_INVALID(x) do { \
@@ -34,10 +35,6 @@
* Forward declarations
*/
-static char
-octet_from_hex(char * p,
- char * ret);
-
static char *
parse_slash(char *p,
char *end);
@@ -388,13 +385,14 @@ ldb_explode_dn(void * mem_ctx,
/* copy each of the attributes to the normalized component */
for (i = 0; i < component->attr_num; i++) {
if (i != 0) {
- *dest = '+';
- dest++;
+ *dest++ = '+';
}
src = component->attributes[i]->rdn;
/* we are guaranteed to have enough space in dest */
- strcpy(dest, src);
+ size = strlen(src);
+ strncpy(dest, src, size + 1);
+ dest += size;
}
ldb_debug(mem_ctx,
@@ -449,7 +447,9 @@ ldb_explode_dn(void * mem_ctx,
src = dn->components[i]->component;
/* we are guaranteed to have enough space in dest */
- strcpy(dest, src);
+ size = strlen(src);
+ strncpy(dest, src, size + 1);
+ dest += size;
}
ldb_debug(mem_ctx, LDB_DEBUG_TRACE, "dn: [%s]\n", dn->dn);
@@ -468,47 +468,6 @@ failed:
}
-static char
-octet_from_hex(char * p,
- char * ret)
-{
- unsigned char low_char;
- unsigned char high_char;
-
- unsigned char low_binary;
- unsigned char high_binary;
-
- if (p[0] == '\0' || p[1] == '\0') {
- return -1;
- }
-
- high_char = p[0];
- low_char = p[1];
-
- if (high_char >= '0' && high_char <= '9') {
- high_binary = high_char - '0';
- } else if (high_char >= 'A' && high_char <= 'F') {
- high_binary = 10 + (high_char - 'A');
- } else if (high_char >= 'a' && high_char <= 'f') {
- high_binary = 10 + (high_char - 'a');
- } else {
- return -1;
- }
-
- if (low_char >= '0' && low_char <= '9') {
- low_binary = low_char - '0';
- } else if (low_char >= 'A' && low_char <= 'F') {
- low_binary = 10 + (low_char - 'A');
- } else if (low_char >= 'a' && low_char <= 'f') {
- low_binary = 10 + (low_char - 'a');
- } else {
- return -1;
- }
-
- *ret = (char) ((high_binary << 4) | low_binary);
- return 0;
-}
-
static char *
parse_slash(char *p,
char *end)
@@ -528,10 +487,11 @@ parse_slash(char *p,
return (end - 1);
default:
- if (*(p + 1) != '\0' && *(p + 2) != '\0') {
- if (octet_from_hex(p + 1, p) < 0) {
- return NULL;
- }
+ if (isxdigit(p[1]) && isxdigit(p[2])) {
+ int x;
+
+ sscanf(p + 1, "%02x", &x);
+ *p = (char) x;
memmove(p + 1, p + 3, end - (p + 3));
return (end - 2);
} else {