*/
-#include "includes.h"
-#include "ldb/include/ldb.h"
-#include <ctype.h>
-
+#include "ldb_includes.h"
+#include "system/locale.h"
/*
a filter is defined by:
struct ldb_val ret;
int slen = str?strlen(str):0;
- ret.data = talloc_size(mem_ctx, slen+1);
+ ret.data = (uint8_t *)talloc_size(mem_ctx, slen+1);
ret.length = 0;
if (ret.data == NULL) return ret;
return ret;
}
+/*
+ encode a string as a RFC2254 binary string, escaping any
+ non-printable or '\' characters. This routine is suitable for use
+ in escaping user data in ldap filters.
+*/
+char *ldb_binary_encode_string(void *mem_ctx, const char *string)
+{
+ struct ldb_val val;
+ val.data = discard_const_p(uint8_t, string);
+ val.length = strlen(string);
+ return ldb_binary_encode(mem_ctx, val);
+}
+
/* find the first matching wildcard */
static char *ldb_parse_find_wildcard(char *value)
{
val++;
}
- ret[val] = NULL;
+ if (ret != NULL) {
+ ret[val] = NULL;
+ }
return ret;
}
}
/* save name */
- name = talloc_memdup(mem_ctx, t, t1 - t + 1);
+ name = (char *)talloc_memdup(mem_ctx, t, t1 - t + 1);
if (name == NULL) return 0;
name[t1 - t] = '\0';
while (*p && ((*p != ')') || ((*p == ')') && (*(p - 1) == '\\')))) p++;
- val = talloc_memdup(mem_ctx, t, p - t + 1);
+ val = (char *)talloc_memdup(mem_ctx, t, p - t + 1);
if (val == NULL) {
talloc_free(name);
return 0;