[SCM] Samba Shared Repository - branch master updated
Andreas Schneider
asn at samba.org
Fri Dec 23 14:18:01 UTC 2022
The branch, master has been updated
via 0c931fb301c waf: Run python tests also with tr_TR locale
via 24275cd800b lib:ldb: Use ldb_ascii_toupper() for case folding
via a8f6fa03ef6 lib:ldb: Add ldb_ascii_toupper()
via 78ca66a1a54 lib:ldb: Remove trailing white spaces in ldb_private.h
via c8e3873e7e6 lib:ldb: Fix trailing whitespaces in common/ldb_utf8.c
via 14751e91a52 lib:ldb: Fix trailing whitespaces in common/attrib_handlers.c
from c515a5b2cc3 smbd: Make send_trans2_replies() static
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 0c931fb301c5137668db671a6d861c5b5769aa18
Author: Andreas Schneider <asn at samba.org>
Date: Fri Nov 18 08:49:29 2022 +0100
waf: Run python tests also with tr_TR locale
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15248
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
Autobuild-Date(master): Fri Dec 23 14:17:31 UTC 2022 on sn-devel-184
commit 24275cd800b05538ae32e29cbe74529076184954
Author: Andreas Schneider <asn at samba.org>
Date: Thu Nov 10 14:44:59 2022 +0100
lib:ldb: Use ldb_ascii_toupper() for case folding
For example there are at least two locales (tr_TR and az_AZ) in glibc
having dotless i transformation different from Latin scripts and GUID
versus Guid comparison would be different there (attribute name would
not match in the test).
See also
https://en.wikipedia.org/wiki/Dotted_and_dotless_I
https://lists.samba.org/archive/samba-technical/2019-December/134659.html
This fixes: LC_ALL=tr_TR.UTF-8 make test
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15248
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit a8f6fa03ef68f086e46539af4d4594b35e638e37
Author: Andreas Schneider <asn at samba.org>
Date: Wed Mar 23 12:45:37 2022 +0100
lib:ldb: Add ldb_ascii_toupper()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15248
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit 78ca66a1a54ede649ca9726e81b420993234b1cf
Author: Andreas Schneider <asn at samba.org>
Date: Thu Nov 10 14:46:47 2022 +0100
lib:ldb: Remove trailing white spaces in ldb_private.h
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15248
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit c8e3873e7e6677720c74882bcc63e72fb03e98cc
Author: Andreas Schneider <asn at samba.org>
Date: Wed Mar 23 12:44:07 2022 +0100
lib:ldb: Fix trailing whitespaces in common/ldb_utf8.c
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15248
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit 14751e91a5218c168f50e0bd998593f425f7f4c0
Author: Andreas Schneider <asn at samba.org>
Date: Wed Mar 23 12:43:36 2022 +0100
lib:ldb: Fix trailing whitespaces in common/attrib_handlers.c
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15248
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/ldb/common/attrib_handlers.c | 49 ++++++++++++++++++++++------------------
lib/ldb/common/ldb_utf8.c | 12 ++++++----
lib/ldb/include/ldb.h | 18 ++++++++++-----
lib/ldb/include/ldb_private.h | 23 +++++++++++++++----
lib/ldb/wscript | 7 ++++++
5 files changed, 72 insertions(+), 37 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/ldb/common/attrib_handlers.c b/lib/ldb/common/attrib_handlers.c
index febf2f414ca..2c30f5235a9 100644
--- a/lib/ldb/common/attrib_handlers.c
+++ b/lib/ldb/common/attrib_handlers.c
@@ -1,4 +1,4 @@
-/*
+/*
ldb database library
Copyright (C) Andrew Tridgell 2005
@@ -7,7 +7,7 @@
** 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
@@ -309,7 +309,7 @@ int ldb_comparison_binary(struct ldb_context *ldb, void *mem_ctx,
compare two case insensitive strings, ignoring multiple whitespaces
and leading and trailing whitespaces
see rfc2252 section 8.1
-
+
try to optimize for the ascii case,
but if we find out an utf8 codepoint revert to slower but correct function
*/
@@ -321,6 +321,7 @@ int ldb_comparison_fold(struct ldb_context *ldb, void *mem_ctx,
char *b1, *b2;
const char *u1, *u2;
int ret;
+
while (n1 && *s1 == ' ') { s1++; n1--; };
while (n2 && *s2 == ' ') { s2++; n2--; };
@@ -345,24 +346,28 @@ int ldb_comparison_fold(struct ldb_context *ldb, void *mem_ctx,
* "domainUpdates"
*/
if (n1 && *s1 == ' ' && (!n2 || !*s2)) {
- while (n1 && *s1 == ' ') { s1++; n1--; }
+ while (n1 && *s1 == ' ') { s1++; n1--; }
}
if (n2 && *s2 == ' ' && (!n1 || !*s1)) {
- while (n2 && *s2 == ' ') { s2++; n2--; }
+ while (n2 && *s2 == ' ') { s2++; n2--; }
}
if (n1 == 0 && n2 != 0) {
- return -(int)toupper(*s2);
+ return -(int)ldb_ascii_toupper(*s2);
}
if (n2 == 0 && n1 != 0) {
- return (int)toupper(*s1);
+ return (int)ldb_ascii_toupper(*s1);
}
if (n1 == 0 && n2 == 0) {
return 0;
}
- return (int)toupper(*s1) - (int)toupper(*s2);
+ return (int)ldb_ascii_toupper(*s1) - (int)ldb_ascii_toupper(*s2);
utf8str:
- /* no need to recheck from the start, just from the first utf8 char found */
+ /*
+ * No need to recheck from the start, just from the first utf8 charu
+ * found. Note that the callback of ldb_casefold() needs to be ascii
+ * compatible.
+ */
b1 = ldb_casefold(ldb, mem_ctx, s1, n1);
b2 = ldb_casefold(ldb, mem_ctx, s2, n2);
@@ -375,9 +380,9 @@ utf8str:
if (ret == 0) {
if (n1 == n2) return 0;
if (n1 > n2) {
- return (int)toupper(s1[n2]);
+ return (int)ldb_ascii_toupper(s1[n2]);
} else {
- return -(int)toupper(s2[n1]);
+ return -(int)ldb_ascii_toupper(s2[n1]);
}
}
return ret;
@@ -403,7 +408,7 @@ utf8str:
talloc_free(b1);
talloc_free(b2);
-
+
return ret;
}
@@ -455,7 +460,7 @@ static int ldb_comparison_dn(struct ldb_context *ldb, void *mem_ctx,
if ( ! ldb_dn_validate(dn2)) {
talloc_free(dn1);
return -1;
- }
+ }
ret = ldb_dn_compare(dn1, dn2);
@@ -523,7 +528,7 @@ static int ldb_canonicalise_generalizedtime(struct ldb_context *ldb, void *mem_c
table of standard attribute handlers
*/
static const struct ldb_schema_syntax ldb_standard_syntaxes[] = {
- {
+ {
.name = LDB_SYNTAX_INTEGER,
.ldif_read_fn = ldb_handler_copy,
.ldif_write_fn = ldb_handler_copy,
@@ -545,35 +550,35 @@ static const struct ldb_schema_syntax ldb_standard_syntaxes[] = {
.canonicalise_fn = ldb_handler_copy,
.comparison_fn = ldb_comparison_binary
},
- {
+ {
.name = LDB_SYNTAX_DIRECTORY_STRING,
.ldif_read_fn = ldb_handler_copy,
.ldif_write_fn = ldb_handler_copy,
.canonicalise_fn = ldb_handler_fold,
.comparison_fn = ldb_comparison_fold
},
- {
+ {
.name = LDB_SYNTAX_DN,
.ldif_read_fn = ldb_handler_copy,
.ldif_write_fn = ldb_handler_copy,
.canonicalise_fn = ldb_canonicalise_dn,
.comparison_fn = ldb_comparison_dn
},
- {
+ {
.name = LDB_SYNTAX_OBJECTCLASS,
.ldif_read_fn = ldb_handler_copy,
.ldif_write_fn = ldb_handler_copy,
.canonicalise_fn = ldb_handler_fold,
.comparison_fn = ldb_comparison_fold
},
- {
+ {
.name = LDB_SYNTAX_UTC_TIME,
.ldif_read_fn = ldb_handler_copy,
.ldif_write_fn = ldb_handler_copy,
.canonicalise_fn = ldb_canonicalise_utctime,
.comparison_fn = ldb_comparison_utctime
},
- {
+ {
.name = LDB_SYNTAX_GENERALIZED_TIME,
.ldif_read_fn = ldb_handler_copy,
.ldif_write_fn = ldb_handler_copy,
@@ -607,8 +612,8 @@ const struct ldb_schema_syntax *ldb_standard_syntax_by_name(struct ldb_context *
return NULL;
}
-int ldb_any_comparison(struct ldb_context *ldb, void *mem_ctx,
- ldb_attr_handler_t canonicalise_fn,
+int ldb_any_comparison(struct ldb_context *ldb, void *mem_ctx,
+ ldb_attr_handler_t canonicalise_fn,
const struct ldb_val *v1,
const struct ldb_val *v2)
{
@@ -619,7 +624,7 @@ int ldb_any_comparison(struct ldb_context *ldb, void *mem_ctx,
/* I could try and bail if tmp_ctx was NULL, but what return
* value would I use?
*
- * It seems easier to continue on the NULL context
+ * It seems easier to continue on the NULL context
*/
ret1 = canonicalise_fn(ldb, tmp_ctx, v1, &v1_canon);
ret2 = canonicalise_fn(ldb, tmp_ctx, v2, &v2_canon);
diff --git a/lib/ldb/common/ldb_utf8.c b/lib/ldb/common/ldb_utf8.c
index 55d8f905d35..f45b72dde50 100644
--- a/lib/ldb/common/ldb_utf8.c
+++ b/lib/ldb/common/ldb_utf8.c
@@ -1,4 +1,4 @@
-/*
+/*
ldb database library
Copyright (C) Andrew Tridgell 2004
@@ -6,7 +6,7 @@
** 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
@@ -62,7 +62,7 @@ char *ldb_casefold_default(void *context, TALLOC_CTX *mem_ctx, const char *s, si
return NULL;
}
for (i=0;ret[i];i++) {
- ret[i] = toupper((unsigned char)ret[i]);
+ ret[i] = ldb_ascii_toupper((unsigned char)ret[i]);
}
return ret;
}
@@ -118,7 +118,7 @@ char *ldb_attr_casefold(TALLOC_CTX *mem_ctx, const char *s)
return NULL;
}
for (i = 0; ret[i]; i++) {
- ret[i] = toupper((unsigned char)ret[i]);
+ ret[i] = ldb_ascii_toupper((unsigned char)ret[i]);
}
return ret;
}
@@ -134,3 +134,7 @@ int ldb_attr_dn(const char *attr)
}
return -1;
}
+
+_PRIVATE_ char ldb_ascii_toupper(char c) {
+ return ('a' <= c && c <= 'z') ? c ^ 0x20 : toupper(c);
+}
diff --git a/lib/ldb/include/ldb.h b/lib/ldb/include/ldb.h
index 68cbfdb6f7a..b3bdbb30f31 100644
--- a/lib/ldb/include/ldb.h
+++ b/lib/ldb/include/ldb.h
@@ -1551,7 +1551,11 @@ const char *ldb_strerror(int ldb_err);
void ldb_set_utf8_default(struct ldb_context *ldb);
/**
- Casefold a string
+ \brief Casefold a string
+
+ Note that the callback needs to be ASCII compatible. So first ASCII needs
+ to be handle before any UTF-8. This is needed to avoid issues with dottet
+ languages.
\param ldb the ldb context
\param mem_ctx the memory context to allocate the result string
@@ -1745,7 +1749,7 @@ char * ldb_ldif_write_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
\return the string containing the LDIF, or NULL on error
- \sa ldb_ldif_message_redacted_string for a safer version of this
+ \sa ldb_ldif_message_redacted_string for a safer version of this
function
*/
char *ldb_ldif_message_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
@@ -1763,7 +1767,7 @@ char *ldb_ldif_message_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
\return the string containing the LDIF, or NULL on error, but
with secret attributes redacted
- \note The secret attributes are specified in a
+ \note The secret attributes are specified in a
'const char * const *' within the LDB_SECRET_ATTRIBUTE_LIST
opaque set on the ldb
@@ -1949,7 +1953,7 @@ struct ldb_message *ldb_msg_new(TALLOC_CTX *mem_ctx);
/**
Find an element within an message
*/
-struct ldb_message_element *ldb_msg_find_element(const struct ldb_message *msg,
+struct ldb_message_element *ldb_msg_find_element(const struct ldb_message *msg,
const char *attr_name);
/**
@@ -1970,7 +1974,7 @@ int ldb_val_equal_exact(const struct ldb_val *v1, const struct ldb_val *v2);
\note This search is case sensitive
*/
-struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el,
+struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el,
struct ldb_val *val);
/**
@@ -2186,7 +2190,9 @@ int ldb_set_debug(struct ldb_context *ldb,
void *context);
/**
- this allows the user to set custom utf8 function for error reporting
+ this allows the user to set custom utf8 function for error reporting. make
+ sure it is able to handle ASCII first, so it prevents issues with dottet
+ languages.
*/
void ldb_set_utf8_fns(struct ldb_context *ldb,
void *context,
diff --git a/lib/ldb/include/ldb_private.h b/lib/ldb/include/ldb_private.h
index 4deb24691ca..7d9a47c8ef3 100644
--- a/lib/ldb/include/ldb_private.h
+++ b/lib/ldb/include/ldb_private.h
@@ -1,4 +1,4 @@
-/*
+/*
ldb database library
Copyright (C) Andrew Tridgell 2004
@@ -8,7 +8,7 @@
** 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
@@ -84,7 +84,7 @@ struct ldb_module {
struct ldb_schema {
void *attribute_handler_override_private;
ldb_attribute_handler_override_fn_t attribute_handler_override;
-
+
/* attribute handling table */
unsigned num_attributes;
struct ldb_schema_attribute *attributes;
@@ -233,10 +233,10 @@ struct ldif_read_file_state {
size_t line_no;
};
-struct ldb_ldif *ldb_ldif_read_file_state(struct ldb_context *ldb,
+struct ldb_ldif *ldb_ldif_read_file_state(struct ldb_context *ldb,
struct ldif_read_file_state *state);
-char *ldb_ldif_write_redacted_trace_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
+char *ldb_ldif_write_redacted_trace_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
const struct ldb_ldif *ldif);
/*
@@ -317,4 +317,17 @@ int ldb_match_message(struct ldb_context *ldb,
const struct ldb_parse_tree *tree,
enum ldb_scope scope, bool *matched);
+/**
+ * @brief Convert a character to uppercase with ASCII precedence.
+ *
+ * This will convert a character to uppercase. If the character is an ASCII
+ * character it will convert it to uppercase ASCII first and then fallback to
+ * localized toupper() from libc.
+ *
+ * @param c The character to convert.
+ *
+ * @return The converted character or c if the conversion was not possible.
+ */
+char ldb_ascii_toupper(char c);
+
#endif
diff --git a/lib/ldb/wscript b/lib/ldb/wscript
index 97a1dcd2e58..2dfac46403f 100644
--- a/lib/ldb/wscript
+++ b/lib/ldb/wscript
@@ -619,6 +619,13 @@ def test(ctx):
'tests/python/index.py',
'tests/python/repack.py'],
extra_env={'SELFTEST_PREFIX': test_prefix})
+ pyret = samba_utils.RUN_PYTHON_TESTS(
+ ['tests/python/api.py',
+ 'tests/python/crash.py',
+ 'tests/python/index.py',
+ 'tests/python/repack.py'],
+ extra_env={'SELFTEST_PREFIX': test_prefix,
+ 'LC_ALL': 'tr_TR.UTF-8'})
print("Python testsuite returned %d" % pyret)
cmocka_ret = 0
--
Samba Shared Repository
More information about the samba-cvs
mailing list