From 0dad5a34273bf5cadcfd4a36d69bdffbf69eb073 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 1 May 2004 09:45:56 +0000 Subject: r435: a major upgrade for ldb - added the ability to mark record attributes as being CASE_INSENSITIVE, WILDCARD or INTEGER. - added the ability to support objectclass subclasses, and to search by a parent class - added internal support for case insensitive versus case sensitive indexing (not UTF8 compliant yet) - cleaned up a number of const warnings - added a number of helper functions for fetching integers, strings and doubles - added a in-memory cache for important database properties, supported by a database sequence number - changed some variable names to avoid conflicts with C++ (This used to be commit f2bf06f25c2e6c744817711c7bedbd1d3b52f994) --- source4/lib/ldb/common/ldb_utf8.c | 87 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 source4/lib/ldb/common/ldb_utf8.c (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c new file mode 100644 index 0000000000..7767b0955e --- /dev/null +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -0,0 +1,87 @@ +/* + ldb database library + + Copyright (C) Andrew Tridgell 2004 + + ** NOTE! The following LGPL license applies to the ldb + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* + * Name: ldb + * + * Component: ldb utf8 handling + * + * Description: case folding and case comparison for UTF8 strings + * + * Author: Andrew Tridgell + */ + +#include "includes.h" + +/* + TODO: + a simple case folding function - will be replaced by a UTF8 aware function later +*/ +char *ldb_casefold(const char *s) +{ + int i; + char *ret = strdup(s); + if (!s) { + errno = ENOMEM; + return NULL; + } + for (i=0;ret[i];i++) { + ret[i] = toupper(ret[i]); + } + return ret; +} + +/* + a caseless compare, optimised for 7 bit + TODO: doesn't yet handle UTF8 +*/ +static int ldb_caseless_cmp(const char *s1, const char *s2) +{ + int i; + for (i=0;s1[i] != 0;i++) { + int c1 = toupper(s1[i]), c2 = toupper(s2[i]); + if (c1 != c2) { + return c1 - c2; + } + } + return s2[i]; +} + +/* + compare two basedn fields + return 0 for match +*/ +int ldb_dn_cmp(const char *dn1, const char *dn2) +{ + return ldb_caseless_cmp(dn1, dn2); +} + +/* + compare two attributes + return 0 for match +*/ +int ldb_attr_cmp(const char *dn1, const char *dn2) +{ + return ldb_caseless_cmp(dn1, dn2); +} -- cgit From d8ce7c6a2acbf371509a23775470e7614bcb6027 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 May 2004 04:40:15 +0000 Subject: r502: modified ldb to allow the use of an external pool memory allocator. The way to use this is to call ldb_set_alloc() with a function pointer to whatever memory allocator you like. It includes a context pointer to allow for pool based allocators. (This used to be commit 3955c482e6c2c9e975a4bb809ec8cb6068e48e34) --- source4/lib/ldb/common/ldb_utf8.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 7767b0955e..1e467d23af 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -38,10 +38,10 @@ TODO: a simple case folding function - will be replaced by a UTF8 aware function later */ -char *ldb_casefold(const char *s) +char *ldb_casefold(struct ldb_context *ldb, const char *s) { int i; - char *ret = strdup(s); + char *ret = ldb_strdup(ldb, s); if (!s) { errno = ENOMEM; return NULL; -- cgit From 26c6b4c70bd85d8030a96651f2a255a4d48fcda1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 01:42:45 +0000 Subject: r3449: more include file reduction the ldb part isn't ideal, I will have to think of a better solution (This used to be commit 6b1f86aea8427a8e957b1aeb0ec2f507297f07cb) --- source4/lib/ldb/common/ldb_utf8.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 1e467d23af..e92d318bae 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -33,6 +33,7 @@ */ #include "includes.h" +#include /* TODO: -- cgit From 8a18778286a16423d7d6e483fdb308a91e294efe Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 16 Nov 2004 09:00:52 +0000 Subject: r3783: - don't use make proto for ldb anymore - split ldh.h out of samba's includes.h - make ldb_context and ldb_module private to the subsystem - use ltdb_ prefix for all ldb_tdb functions metze (This used to be commit f5ee40d6ce8224e280070975efc9911558fe675c) --- source4/lib/ldb/common/ldb_utf8.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index e92d318bae..01bd8eb9ac 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -33,6 +33,8 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" #include /* -- cgit From 1a988ec9af7960616fb4661b20d86ff05146d836 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 2 Jan 2005 07:49:29 +0000 Subject: r4474: - converted ldb to use talloc internally - added gcov flags to Makefile.ldb - expanded ldb test suite to get more coverage (This used to be commit 0ab98f50a7e0fe15347a99e5c29a6590a87729a0) --- source4/lib/ldb/common/ldb_utf8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 01bd8eb9ac..577766d9f7 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -44,7 +44,7 @@ char *ldb_casefold(struct ldb_context *ldb, const char *s) { int i; - char *ret = ldb_strdup(ldb, s); + char *ret = talloc_strdup(ldb, s); if (!s) { errno = ENOMEM; return NULL; -- cgit From a1ba224107fbcf6f8a9a3091f42cde2a0c47f85e Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 4 Jun 2005 17:13:43 +0000 Subject: r7276: - moved static tdb function ltdb_dn_fold() into common/ so that it can be called from multiple backends. (ldb_sqlite3 needs it too.) Added parameter for a callback function that determines whether an attribute needs case folding. - begin to prepare for sqlite3 in build process - work-in-progress updates, on ldb_sqlite3 (This used to be commit a80bced0b96ffb655559a43cf7f4d7a34deb5a7d) --- source4/lib/ldb/common/ldb_utf8.c | 77 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 577766d9f7..9cbb5646dd 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -88,3 +88,80 @@ int ldb_attr_cmp(const char *dn1, const char *dn2) { return ldb_caseless_cmp(dn1, dn2); } + + +/* + casefold a dn. We need to uppercase the attribute names, and the + attribute values of case insensitive attributes. We also need to remove + extraneous spaces between elements +*/ +char *ldb_dn_fold(struct ldb_module *module, const char *dn, int (*case_fold_attr_fn)(struct ldb_module * module, char * attr)) +{ + const char *dn_orig = dn; + struct ldb_context *ldb = module->ldb; + TALLOC_CTX *tmp_ctx = talloc_new(ldb); + char *ret; + size_t len; + + ret = talloc_strdup(tmp_ctx, ""); + if (ret == NULL) goto failed; + + while ((len = strcspn(dn, ",")) > 0) { + char *p = strchr(dn, '='); + char *attr, *value; + int case_fold_required; + + if (p == NULL || (p-dn) > len) goto failed; + + attr = talloc_strndup(tmp_ctx, dn, p-dn); + if (attr == NULL) goto failed; + + /* trim spaces from the attribute name */ + while (' ' == *attr) attr++; + while (' ' == attr[strlen(attr)-1]) { + attr[strlen(attr)-1] = 0; + } + if (*attr == 0) goto failed; + + value = talloc_strndup(tmp_ctx, p+1, len-(p+1-dn)); + if (value == NULL) goto failed; + + /* trim spaces from the value */ + while (' ' == *value) value++; + while (' ' == value[strlen(value)-1]) { + value[strlen(value)-1] = 0; + } + if (*value == 0) goto failed; + + case_fold_required = (* case_fold_attr_fn)(module, attr); + + attr = ldb_casefold(ldb, attr); + if (attr == NULL) goto failed; + talloc_steal(tmp_ctx, attr); + + if (case_fold_required) { + value = ldb_casefold(ldb, value); + if (value == NULL) goto failed; + talloc_steal(tmp_ctx, value); + } + + if (dn[len] == ',') { + ret = talloc_asprintf_append(ret, "%s=%s,", attr, value); + } else { + ret = talloc_asprintf_append(ret, "%s=%s", attr, value); + } + if (ret == NULL) goto failed; + + dn += len; + if (*dn == ',') dn++; + } + + talloc_steal(ldb, ret); + talloc_free(tmp_ctx); + return ret; + +failed: + talloc_free(tmp_ctx); + return ldb_casefold(ldb, dn_orig); +} + -- cgit From a6717fae681f89cf427e282d645029ca0b3e4d44 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Thu, 9 Jun 2005 02:47:26 +0000 Subject: r7418: work in progress (This used to be commit 2a13e7655b1bce88694ddbb6a4d9349008ba42f0) --- source4/lib/ldb/common/ldb_utf8.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 9cbb5646dd..dc25d6cf13 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -41,10 +41,10 @@ TODO: a simple case folding function - will be replaced by a UTF8 aware function later */ -char *ldb_casefold(struct ldb_context *ldb, const char *s) +char *ldb_casefold(void *mem_ctx, const char *s) { int i; - char *ret = talloc_strdup(ldb, s); + char *ret = talloc_strdup(mem_ctx, s); if (!s) { errno = ENOMEM; return NULL; -- cgit From f021dffb6991138213967521c743f03f474f9af9 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 15 Jun 2005 02:43:42 +0000 Subject: r7601: ldb_sqlite3 work in progress (This used to be commit 0a64948152a446b5e127578d49b1ed8a90a1a222) --- source4/lib/ldb/common/ldb_utf8.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index dc25d6cf13..35249c4b70 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -95,11 +95,13 @@ int ldb_attr_cmp(const char *dn1, const char *dn2) attribute values of case insensitive attributes. We also need to remove extraneous spaces between elements */ -char *ldb_dn_fold(struct ldb_module *module, const char *dn, int (*case_fold_attr_fn)(struct ldb_module * module, char * attr)) +char *ldb_dn_fold(void * mem_ctx, + const char * dn, + void * user_data, + int (* case_fold_attr_fn)(void * user_data, char * attr)) { const char *dn_orig = dn; - struct ldb_context *ldb = module->ldb; - TALLOC_CTX *tmp_ctx = talloc_new(ldb); + TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); char *ret; size_t len; @@ -133,14 +135,14 @@ char *ldb_dn_fold(struct ldb_module *module, const char *dn, int (*case_fold_att } if (*value == 0) goto failed; - case_fold_required = (* case_fold_attr_fn)(module, attr); + case_fold_required = (* case_fold_attr_fn)(user_data, attr); - attr = ldb_casefold(ldb, attr); + attr = ldb_casefold(tmp_ctx, attr); if (attr == NULL) goto failed; talloc_steal(tmp_ctx, attr); if (case_fold_required) { - value = ldb_casefold(ldb, value); + value = ldb_casefold(tmp_ctx, value); if (value == NULL) goto failed; talloc_steal(tmp_ctx, value); } @@ -156,12 +158,12 @@ char *ldb_dn_fold(struct ldb_module *module, const char *dn, int (*case_fold_att if (*dn == ',') dn++; } - talloc_steal(ldb, ret); + talloc_steal(mem_ctx, ret); talloc_free(tmp_ctx); return ret; failed: talloc_free(tmp_ctx); - return ldb_casefold(ldb, dn_orig); + return ldb_casefold(mem_ctx, dn_orig); } -- cgit From ed3d8091ce2b2014350a2f7f22202dde6846a130 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 18 Jun 2005 07:42:21 +0000 Subject: r7709: - convert ldb to use popt, so that it can interact with the samba cmdline credentials code (which will be done soon) - added a ldb_init() call, and changed ldb_connect() to take a ldb context. This allows for much better error handling in ldb_connect(), and also made the popt conversion easier - fixed up all the existing backends with the new syntax - improved error handling in *_connect() - fixed a crash bug in the new case_fold_required() code - ensured that ltdb_rename() and all ltdb_search() paths get the read lock - added a ldb_oom() macro to make it easier to report out of memory situations in ldb code (This used to be commit f648fdf187669d6d87d01dd4e786b03cd420f220) --- source4/lib/ldb/common/ldb_utf8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 35249c4b70..ae35ad81b6 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -135,7 +135,7 @@ char *ldb_dn_fold(void * mem_ctx, } if (*value == 0) goto failed; - case_fold_required = (* case_fold_attr_fn)(user_data, attr); + case_fold_required = case_fold_attr_fn(user_data, attr); attr = ldb_casefold(tmp_ctx, attr); if (attr == NULL) goto failed; -- cgit From 1702f52498168c0437416dec1014cedead634774 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 26 Jun 2005 23:59:22 +0000 Subject: r7936: new ldb_dn_explode and ldb_dn_casefold functions and co (This used to be commit 7ccf21ab4eeb9821e457308a239f2103a106fb12) --- source4/lib/ldb/common/ldb_utf8.c | 80 +-------------------------------------- 1 file changed, 1 insertion(+), 79 deletions(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index ae35ad81b6..0c1ea6ca81 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -59,7 +59,7 @@ char *ldb_casefold(void *mem_ctx, const char *s) a caseless compare, optimised for 7 bit TODO: doesn't yet handle UTF8 */ -static int ldb_caseless_cmp(const char *s1, const char *s2) +int ldb_caseless_cmp(const char *s1, const char *s2) { int i; for (i=0;s1[i] != 0;i++) { @@ -89,81 +89,3 @@ int ldb_attr_cmp(const char *dn1, const char *dn2) return ldb_caseless_cmp(dn1, dn2); } - -/* - casefold a dn. We need to uppercase the attribute names, and the - attribute values of case insensitive attributes. We also need to remove - extraneous spaces between elements -*/ -char *ldb_dn_fold(void * mem_ctx, - const char * dn, - void * user_data, - int (* case_fold_attr_fn)(void * user_data, char * attr)) -{ - const char *dn_orig = dn; - TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); - char *ret; - size_t len; - - ret = talloc_strdup(tmp_ctx, ""); - if (ret == NULL) goto failed; - - while ((len = strcspn(dn, ",")) > 0) { - char *p = strchr(dn, '='); - char *attr, *value; - int case_fold_required; - - if (p == NULL || (p-dn) > len) goto failed; - - attr = talloc_strndup(tmp_ctx, dn, p-dn); - if (attr == NULL) goto failed; - - /* trim spaces from the attribute name */ - while (' ' == *attr) attr++; - while (' ' == attr[strlen(attr)-1]) { - attr[strlen(attr)-1] = 0; - } - if (*attr == 0) goto failed; - - value = talloc_strndup(tmp_ctx, p+1, len-(p+1-dn)); - if (value == NULL) goto failed; - - /* trim spaces from the value */ - while (' ' == *value) value++; - while (' ' == value[strlen(value)-1]) { - value[strlen(value)-1] = 0; - } - if (*value == 0) goto failed; - - case_fold_required = case_fold_attr_fn(user_data, attr); - - attr = ldb_casefold(tmp_ctx, attr); - if (attr == NULL) goto failed; - talloc_steal(tmp_ctx, attr); - - if (case_fold_required) { - value = ldb_casefold(tmp_ctx, value); - if (value == NULL) goto failed; - talloc_steal(tmp_ctx, value); - } - - if (dn[len] == ',') { - ret = talloc_asprintf_append(ret, "%s=%s,", attr, value); - } else { - ret = talloc_asprintf_append(ret, "%s=%s", attr, value); - } - if (ret == NULL) goto failed; - - dn += len; - if (*dn == ',') dn++; - } - - talloc_steal(mem_ctx, ret); - talloc_free(tmp_ctx); - return ret; - -failed: - talloc_free(tmp_ctx); - return ldb_casefold(mem_ctx, dn_orig); -} - -- cgit From a06d66a3a669c3a0a0f816438e2b3e91e208f398 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 1 Jul 2005 06:21:26 +0000 Subject: r8037: a fairly major update to the internals of ldb. Changes are: - moved the knowledge of attribute types out of ldb_tdb and into the generic ldb code. This allows the ldb_match() message match logic to be generic, so it can be used by other backend - added the generic ability to load attribute handlers, for canonicalisation, compare, ldif read and ldif write. In the future this will be used by the schema module to allow us to correctly obey the attributetype schema elements - added attribute handlers for some of the core ldap attribute types, Integer, DirectoryString, DN, ObjectClass etc - added automatic registration of attribute handlers for well-known attribute names 'cn', 'dc', 'dn', 'ou' and 'objectClass' - converted the objectSid special handlers for Samba to the new system - added more correct handling of indexing in tdb backend based on the attribute canonicalisation function - added generic support for subclasses, moving it out of the tdb backend. This will be used in future by the schema module - fixed several bugs in the dn_explode code. It still needs more work, but doesn't corrupt ldb dbs any more. (This used to be commit 944c5844ab441b96d8e5d7b2d151982139d1fab9) --- source4/lib/ldb/common/ldb_utf8.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 0c1ea6ca81..38c117d7e0 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -84,8 +84,8 @@ int ldb_dn_cmp(const char *dn1, const char *dn2) compare two attributes return 0 for match */ -int ldb_attr_cmp(const char *dn1, const char *dn2) +int ldb_attr_cmp(const char *attr1, const char *attr2) { - return ldb_caseless_cmp(dn1, dn2); + return ldb_caseless_cmp(attr1, attr2); } -- cgit From 61edb97bdfabf1ab313fbec5f47f5e6c8a79da1a Mon Sep 17 00:00:00 2001 From: Love Hörnquist Åstrand Date: Tue, 12 Jul 2005 22:22:59 +0000 Subject: r8394: Make sure the argument to ctype is*(3) macros are unsigned char as required by ISO C99. (This used to be commit 56fd21c806e816cf4c3d23881f26474f858b45e2) --- source4/lib/ldb/common/ldb_utf8.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 38c117d7e0..5df5a6bba7 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -50,7 +50,7 @@ char *ldb_casefold(void *mem_ctx, const char *s) return NULL; } for (i=0;ret[i];i++) { - ret[i] = toupper(ret[i]); + ret[i] = toupper((unsigned char)ret[i]); } return ret; } @@ -63,7 +63,8 @@ int ldb_caseless_cmp(const char *s1, const char *s2) { int i; for (i=0;s1[i] != 0;i++) { - int c1 = toupper(s1[i]), c2 = toupper(s2[i]); + int c1 = toupper((unsigned char)s1[i]), + c2 = toupper((unsigned char)s2[i]); if (c1 != c2) { return c1 - c2; } -- cgit From cb2c43f7b032c26adf82f3ba7d6e3dc855f89fa4 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 16 Jul 2005 18:16:32 +0000 Subject: r8515: ldb_dn_cmp now uses ldb_dn_compare so that the DNs are compared on a content level not ona form level, his means that the 2 DNs: a) cn= user, dc=this, dc = is,dc=test b) cn=user,dc=this,dc=is,dc=test are now identical even if the string form differ (spaces) (This used to be commit 76d496c30867ae80434483a34b0d842523aed762) --- source4/lib/ldb/common/ldb_utf8.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 5df5a6bba7..cd68180f77 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -72,15 +72,6 @@ int ldb_caseless_cmp(const char *s1, const char *s2) return s2[i]; } -/* - compare two basedn fields - return 0 for match -*/ -int ldb_dn_cmp(const char *dn1, const char *dn2) -{ - return ldb_caseless_cmp(dn1, dn2); -} - /* compare two attributes return 0 for match -- cgit From a599edf04cbdeef9014923ba0d3713b8ff84f266 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Oct 2005 06:10:23 +0000 Subject: r10913: This patch isn't as big as it looks ... most of the changes are fixes to make all the ldb code compile without warnings on gcc4. Unfortunately That required a lot of casts :-( I have also added the start of an 'operational' module, which will replace the timestamp module, plus add support for some other operational attributes In ldb_msg_*() I added some new utility functions to make the operational module sane, and remove the 'ldb' argument from the ldb_msg_add_*() functions. That argument was only needed back in the early days of ldb when we didn't use the hierarchical talloc and thus needed a place to get the allocation function from. Now its just a pain to pass around everywhere. Also added a ldb_debug_set() function that calls ldb_debug() plus sets the result using ldb_set_errstring(). That saves on some awkward coding in a few places. (This used to be commit f6818daecca95760c12f79fd307770cbe3346f57) --- source4/lib/ldb/common/ldb_utf8.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index cd68180f77..69faeb46d3 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -80,4 +80,3 @@ int ldb_attr_cmp(const char *attr1, const char *attr2) { return ldb_caseless_cmp(attr1, attr2); } - -- cgit From e2ec8e5e80fdf7f2819c7e6014b1f1f443e032a8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 13 Oct 2005 07:54:38 +0000 Subject: r10957: make a comment clearer (This used to be commit d379fb5f101155edd5f266ae9aaae4e7ac7bd76b) --- source4/lib/ldb/common/ldb_utf8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 69faeb46d3..61334bce09 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -73,7 +73,7 @@ int ldb_caseless_cmp(const char *s1, const char *s2) } /* - compare two attributes + compare two attribute names return 0 for match */ int ldb_attr_cmp(const char *attr1, const char *attr2) -- cgit From 804cf59a489dd41a83fda56acfec4e9f561b1245 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 28 Oct 2005 07:05:32 +0000 Subject: r11364: added a ldb_attr_dn() function for testing if an attribute name is "dn" or "distinguishedName". This makes us a bit more consistent (This used to be commit b41b374b55f9a056c47ffa2ff88aa5272dbc42fc) --- source4/lib/ldb/common/ldb_utf8.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 61334bce09..a0aad12658 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -80,3 +80,15 @@ int ldb_attr_cmp(const char *attr1, const char *attr2) { return ldb_caseless_cmp(attr1, attr2); } + +/* + we accept either 'dn' or 'distinguishedName' for a distinguishedName +*/ +int ldb_attr_dn(const char *attr) +{ + if (ldb_attr_cmp(attr, "dn") == 0 || + ldb_attr_cmp(attr, "distinguishedName") == 0) { + return 0; + } + return -1; +} -- cgit From 4d1c5a023cf6680474bd8d8be73f576d155cfe81 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 10 Jan 2006 16:48:32 +0000 Subject: r12829: fix ldb headers, to not include '<...>' files in .c files this helps in getting symbol -fvisibility=hidden (GCC 4 feature) working later. metze (This used to be commit 380938e97f31c7860aed1e73cc0110c6e17b472e) --- source4/lib/ldb/common/ldb_utf8.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index a0aad12658..4a29ac45f7 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -33,9 +33,7 @@ */ #include "includes.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_private.h" -#include +#include "ldb/include/includes.h" /* TODO: -- cgit From ce4f56dbdc07f3f31664f057888af93ea30284f2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 1 Feb 2006 05:24:19 +0000 Subject: r13278: remove a silly strcasecmp() replacement (This used to be commit 6ec71ffbc141df398aff3e11c45e35e15192c66f) --- source4/lib/ldb/common/ldb_utf8.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 4a29ac45f7..c2d31d440b 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -59,15 +59,7 @@ char *ldb_casefold(void *mem_ctx, const char *s) */ int ldb_caseless_cmp(const char *s1, const char *s2) { - int i; - for (i=0;s1[i] != 0;i++) { - int c1 = toupper((unsigned char)s1[i]), - c2 = toupper((unsigned char)s2[i]); - if (c1 != c2) { - return c1 - c2; - } - } - return s2[i]; + return strcasecmp(s1, s2); } /* -- cgit From f5ebc8e404f4397c0ef2c8b838984df1767c955c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 00:38:48 +0000 Subject: r13324: From now on check attribute names obey rfc2251 Also add a way to provide utf8 compliant functions by registering them with ldb_set_utf8_fns() Next comes code to register samba internal utf8 functions. Simo. (This used to be commit ac9b8a41ffca8e06c5e849d544d3203a665b8e0d) --- source4/lib/ldb/common/ldb_utf8.c | 81 +++++++++++++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 7 deletions(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index c2d31d440b..4735b35af6 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -35,11 +35,29 @@ #include "includes.h" #include "ldb/include/includes.h" + /* - TODO: - a simple case folding function - will be replaced by a UTF8 aware function later + this allow the user to pass in a caseless comparison + function to handle utf8 caseless comparisons + */ +void ldb_set_utf8_fns(struct ldb_context *ldb, + void *context, + int (*cmp)(void *, const char *, const char *), + char *(*casefold)(void *, void *, const char *)) +{ + if (context) + ldb->utf8_fns.context = context; + if (cmp) + ldb->utf8_fns.caseless_cmp = cmp; + if (casefold) + ldb->utf8_fns.casefold = casefold; +} + +/* + a simple case folding function + NOTE: does not handle UTF8 */ -char *ldb_casefold(void *mem_ctx, const char *s) +char *ldb_casefold_default(void *context, void *mem_ctx, const char *s) { int i; char *ret = talloc_strdup(mem_ctx, s); @@ -55,20 +73,69 @@ char *ldb_casefold(void *mem_ctx, const char *s) /* a caseless compare, optimised for 7 bit - TODO: doesn't yet handle UTF8 + NOTE: doesn't handle UTF8 */ -int ldb_caseless_cmp(const char *s1, const char *s2) + +int ldb_caseless_cmp_default(void *context, const char *s1, const char *s2) +{ + return strcasecmp(s1,s2); +} + +void ldb_set_utf8_default(struct ldb_context *ldb) +{ + ldb_set_utf8_fns(ldb, NULL, ldb_caseless_cmp_default, ldb_casefold_default); +} + +char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s) +{ + return ldb->utf8_fns.casefold(ldb->utf8_fns.context, mem_ctx, s); +} + +int ldb_caseless_cmp(struct ldb_context *ldb, const char *s1, const char *s2) +{ + return ldb->utf8_fns.caseless_cmp(ldb->utf8_fns.context, s1, s2); +} + +/* + check the attribute name is valid according to rfc2251 + returns 1 if the name is ok + */ + +int ldb_valid_attr_name(const char *s) { - return strcasecmp(s1, s2); + int i; + + if (!s || !s[0]) + return 0; + + /* handle special ldb_tdb wildcard */ + if (strcmp(s, "*") == 0) return 1; + + for (i = 0; s[i]; i++) { + if (! isascii(s[i])) { + return 0; + } + if (i == 0) { /* first char must be an alpha (or our special '@' identifier) */ + if (! (isalpha(s[i]) || (s[i] == '@'))) { + return 0; + } + } else { + if (! (isalnum(s[i]) || (s[i] == '-'))) { + return 0; + } + } + } + return 1; } /* compare two attribute names + attribute names are restricted by rfc2251 so using strcasecmp here is ok. return 0 for match */ int ldb_attr_cmp(const char *attr1, const char *attr2) { - return ldb_caseless_cmp(attr1, attr2); + return strcasecmp(attr1, attr2); } /* -- cgit From 88279373abc07fa50a969135eb5ecf58d6c40cc7 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 05:59:48 +0000 Subject: r13328: After the attribute name check cleanup it turned up ldb_caseless_cmp() was used just in one places and by mistake, as there we should have been using ldb_attr_cmp() Remove ldb_caseless_cmp() ... going on with the cleanup and utf8 compliance effort. Simo. (This used to be commit afda68d7bf655a9145648856d29e6e64b9f21aa3) --- source4/lib/ldb/common/ldb_utf8.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 4735b35af6..1b7319915b 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -42,13 +42,10 @@ */ void ldb_set_utf8_fns(struct ldb_context *ldb, void *context, - int (*cmp)(void *, const char *, const char *), char *(*casefold)(void *, void *, const char *)) { if (context) ldb->utf8_fns.context = context; - if (cmp) - ldb->utf8_fns.caseless_cmp = cmp; if (casefold) ldb->utf8_fns.casefold = casefold; } @@ -71,19 +68,9 @@ char *ldb_casefold_default(void *context, void *mem_ctx, const char *s) return ret; } -/* - a caseless compare, optimised for 7 bit - NOTE: doesn't handle UTF8 -*/ - -int ldb_caseless_cmp_default(void *context, const char *s1, const char *s2) -{ - return strcasecmp(s1,s2); -} - void ldb_set_utf8_default(struct ldb_context *ldb) { - ldb_set_utf8_fns(ldb, NULL, ldb_caseless_cmp_default, ldb_casefold_default); + ldb_set_utf8_fns(ldb, NULL, ldb_casefold_default); } char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s) @@ -91,11 +78,6 @@ char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s) return ldb->utf8_fns.casefold(ldb->utf8_fns.context, mem_ctx, s); } -int ldb_caseless_cmp(struct ldb_context *ldb, const char *s1, const char *s2) -{ - return ldb->utf8_fns.caseless_cmp(ldb->utf8_fns.context, s1, s2); -} - /* check the attribute name is valid according to rfc2251 returns 1 if the name is ok -- cgit From 04396c36d3ee8300b2b73ea8b43a45ea1b250828 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 06:57:28 +0000 Subject: r13333: revert previous commit I will use ldb_caseless_cmp in attrib_handlers to correctly support utf8 comparisons add an ldb_attr_Casefold function for attribute names and use it instead of casefold in the right places (This used to be commit 3b4eb2413bbce059dde69f35c03cdc3cc2ba85c5) --- source4/lib/ldb/common/ldb_utf8.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 1b7319915b..743e976e84 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -42,10 +42,13 @@ */ void ldb_set_utf8_fns(struct ldb_context *ldb, void *context, + int (*cmp)(void *, const char *, const char *), char *(*casefold)(void *, void *, const char *)) { if (context) ldb->utf8_fns.context = context; + if (cmp) + ldb->utf8_fns.caseless_cmp = cmp; if (casefold) ldb->utf8_fns.casefold = casefold; } @@ -68,9 +71,19 @@ char *ldb_casefold_default(void *context, void *mem_ctx, const char *s) return ret; } +/* + a caseless compare, optimised for 7 bit + NOTE: doesn't handle UTF8 +*/ + +int ldb_caseless_cmp_default(void *context, const char *s1, const char *s2) +{ + return strcasecmp(s1,s2); +} + void ldb_set_utf8_default(struct ldb_context *ldb) { - ldb_set_utf8_fns(ldb, NULL, ldb_casefold_default); + ldb_set_utf8_fns(ldb, NULL, ldb_caseless_cmp_default, ldb_casefold_default); } char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s) @@ -78,6 +91,11 @@ char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s) return ldb->utf8_fns.casefold(ldb->utf8_fns.context, mem_ctx, s); } +int ldb_caseless_cmp(struct ldb_context *ldb, const char *s1, const char *s2) +{ + return ldb->utf8_fns.caseless_cmp(ldb->utf8_fns.context, s1, s2); +} + /* check the attribute name is valid according to rfc2251 returns 1 if the name is ok @@ -112,7 +130,8 @@ int ldb_valid_attr_name(const char *s) /* compare two attribute names - attribute names are restricted by rfc2251 so using strcasecmp here is ok. + attribute names are restricted by rfc2251 so using + strcasecmp and toupper here is ok. return 0 for match */ int ldb_attr_cmp(const char *attr1, const char *attr2) @@ -120,6 +139,20 @@ int ldb_attr_cmp(const char *attr1, const char *attr2) return strcasecmp(attr1, attr2); } +char *ldb_attr_casefold(void *mem_ctx, const char *s) +{ + int i; + char *ret = talloc_strdup(mem_ctx, s); + if (!s) { + errno = ENOMEM; + return NULL; + } + for (i = 0; ret[i]; i++) { + ret[i] = toupper((unsigned char)ret[i]); + } + return ret; +} + /* we accept either 'dn' or 'distinguishedName' for a distinguishedName */ -- cgit From 76036d37b42d0c77e57b288af410b931c51fea81 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 18:30:30 +0000 Subject: r13349: In the end I could not use ldb_caseless_cmp in attrib_handler.c functions remove it again Simo (This used to be commit 513ff499071e6cb5e608a82430718021f72997bd) --- source4/lib/ldb/common/ldb_utf8.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 743e976e84..1951e6edca 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -42,13 +42,10 @@ */ void ldb_set_utf8_fns(struct ldb_context *ldb, void *context, - int (*cmp)(void *, const char *, const char *), char *(*casefold)(void *, void *, const char *)) { if (context) ldb->utf8_fns.context = context; - if (cmp) - ldb->utf8_fns.caseless_cmp = cmp; if (casefold) ldb->utf8_fns.casefold = casefold; } @@ -71,19 +68,9 @@ char *ldb_casefold_default(void *context, void *mem_ctx, const char *s) return ret; } -/* - a caseless compare, optimised for 7 bit - NOTE: doesn't handle UTF8 -*/ - -int ldb_caseless_cmp_default(void *context, const char *s1, const char *s2) -{ - return strcasecmp(s1,s2); -} - void ldb_set_utf8_default(struct ldb_context *ldb) { - ldb_set_utf8_fns(ldb, NULL, ldb_caseless_cmp_default, ldb_casefold_default); + ldb_set_utf8_fns(ldb, NULL, ldb_casefold_default); } char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s) @@ -91,11 +78,6 @@ char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s) return ldb->utf8_fns.casefold(ldb->utf8_fns.context, mem_ctx, s); } -int ldb_caseless_cmp(struct ldb_context *ldb, const char *s1, const char *s2) -{ - return ldb->utf8_fns.caseless_cmp(ldb->utf8_fns.context, s1, s2); -} - /* check the attribute name is valid according to rfc2251 returns 1 if the name is ok -- cgit From 014f70008fcfdb631031c48aa9654ad5b42e62f9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 04:58:06 +0000 Subject: r18130: the move to system/ in libreplace broke some things ... should be happier now (This used to be commit 18542f184f75074e56a9793a9e3b6c6d747bb9e6) --- source4/lib/ldb/common/ldb_utf8.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 1951e6edca..d2d12b8f51 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -34,6 +34,7 @@ #include "includes.h" #include "ldb/include/includes.h" +#include "system/locale.h" /* -- cgit From 9bbc8736e75c7c632b7d274b1f189caf44e78893 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 4 Oct 2006 19:45:34 +0000 Subject: r19074: Merge from 3_0: Fix a potential NULL dereference. Volker (This used to be commit af72af684bca68c1759be1357f817db7be699eed) --- source4/lib/ldb/common/ldb_utf8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index d2d12b8f51..86ed40535a 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -126,7 +126,7 @@ char *ldb_attr_casefold(void *mem_ctx, const char *s) { int i; char *ret = talloc_strdup(mem_ctx, s); - if (!s) { + if (!ret) { errno = ENOMEM; return NULL; } -- cgit From 4f8b4a8ef19da2bcbeea1ae79e9ebbdb8de08169 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 26 Nov 2006 04:39:17 +0000 Subject: r19906: ldb_attr_cmp is used a lot remove unneded overhead of a function call (This used to be commit 3ca25867621af049c6cc52e919fa46dd26c31918) --- source4/lib/ldb/common/ldb_utf8.c | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 86ed40535a..99043ae2af 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -111,17 +111,6 @@ int ldb_valid_attr_name(const char *s) return 1; } -/* - compare two attribute names - attribute names are restricted by rfc2251 so using - strcasecmp and toupper here is ok. - return 0 for match -*/ -int ldb_attr_cmp(const char *attr1, const char *attr2) -{ - return strcasecmp(attr1, attr2); -} - char *ldb_attr_casefold(void *mem_ctx, const char *s) { int i; -- cgit From 52fb06edc25e8538c413df1aaabba18c859a00cf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 5 May 2007 18:50:56 +0000 Subject: r22681: Fix standalone ldb build when parent directory name != ldb. (This used to be commit 1093875d59f1ea9b8bd82277d4f9d8366e584952) --- source4/lib/ldb/common/ldb_utf8.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 99043ae2af..832f91a6ba 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -32,8 +32,7 @@ * Author: Andrew Tridgell */ -#include "includes.h" -#include "ldb/include/includes.h" +#include "ldb_includes.h" #include "system/locale.h" -- cgit From b8d69a7ea2505b706ff7c74d7c97bc89d82dfa07 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:46:15 +0000 Subject: r23795: more v2->v3 conversion (This used to be commit 84b468b2f8f2dffda89593f816e8bc6a8b6d42ac) --- source4/lib/ldb/common/ldb_utf8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 832f91a6ba..b0f8905ea5 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -10,7 +10,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- cgit From 6c973f4e8ccbcb6c9275f8a54e26abb19df7e15a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 03:42:26 +0000 Subject: r23798: updated old Temple Place FSF addresses to new URL (This used to be commit 40c0919aaa9c1b14bbaebb95ecce53eb0380fdbb) --- source4/lib/ldb/common/ldb_utf8.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index b0f8905ea5..b7b4a60122 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -18,8 +18,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ /* -- cgit From cc43037f19056ed24d7fffa54456d597c63ad105 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 22 Aug 2008 17:36:56 +1000 Subject: fixed a problem with length limited ldap values The core ldb code for string matching assumed NULL terminated strings, whereas the anr module used data_blob_const() to effectively truncate a ldb_val by changing its length. The ldb code is supposed to be based around length limited blobs, not NULL terminated strings, so the correct fix was to change the string comparison functions to be length limited (This used to be commit 26c6aa5a80ffaf06fc33f30a6533f8f16ef538bc) --- source4/lib/ldb/common/ldb_utf8.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/lib/ldb/common/ldb_utf8.c') diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index b7b4a60122..69ee2b6964 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -40,8 +40,8 @@ function to handle utf8 caseless comparisons */ void ldb_set_utf8_fns(struct ldb_context *ldb, - void *context, - char *(*casefold)(void *, void *, const char *)) + void *context, + char *(*casefold)(void *, void *, const char *, size_t)) { if (context) ldb->utf8_fns.context = context; @@ -53,10 +53,10 @@ void ldb_set_utf8_fns(struct ldb_context *ldb, a simple case folding function NOTE: does not handle UTF8 */ -char *ldb_casefold_default(void *context, void *mem_ctx, const char *s) +char *ldb_casefold_default(void *context, void *mem_ctx, const char *s, size_t n) { int i; - char *ret = talloc_strdup(mem_ctx, s); + char *ret = talloc_strndup(mem_ctx, s, n); if (!s) { errno = ENOMEM; return NULL; @@ -72,9 +72,9 @@ void ldb_set_utf8_default(struct ldb_context *ldb) ldb_set_utf8_fns(ldb, NULL, ldb_casefold_default); } -char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s) +char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s, size_t n) { - return ldb->utf8_fns.casefold(ldb->utf8_fns.context, mem_ctx, s); + return ldb->utf8_fns.casefold(ldb->utf8_fns.context, mem_ctx, s, n); } /* -- cgit