[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Tue Aug 5 19:28:04 MDT 2014
The branch, master has been updated
via 40386ee locking: posix_lock_list does not use "fsp"
via 380c282 locking: Avoid a pointless cast
via 64271c4 lib: strings: Simplify strcasecmp
via ca16171 s4: tests: Added local.charset test for Bug 10716 - smbd constantly crashes when filename contains non-ascii character
via dfe8dd8 lib: strings: Fix the behavior of strncasecmp_m_handle() in the face of bad conversions.
via 9380478 lib: strings: Fix the behavior of strcasecmp_m_handle() in the face of bad conversions.
from 88f6a6c ctdb-locking: Add per database queues for pending and active lock requests
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 40386ee78dc33ec349b74c6af0fb9c57a2680642
Author: Volker Lendecke <vl at samba.org>
Date: Sun Aug 3 16:28:50 2014 +0200
locking: posix_lock_list does not use "fsp"
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Wed Aug 6 03:27:36 CEST 2014 on sn-devel-104
commit 380c282d440f07ece2abc2c0c1d9aa10939bdd05
Author: Volker Lendecke <vl at samba.org>
Date: Sun Aug 3 11:51:40 2014 +0200
locking: Avoid a pointless cast
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 64271c493df66f1dc67fae7fa14ec75f49db65af
Author: Volker Lendecke <vl at samba.org>
Date: Tue Aug 5 09:21:07 2014 +0000
lib: strings: Simplify strcasecmp
This makes us fallback to strcasecmp early if any INVALID_CODEPOINT
appears. Without this patch we just continue to compare if both strings
happen to have an INVALID_CODEPOINT in the same spot.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit ca1617121a2a6418c2e3ab7a7ce92ddaa1368ce2
Author: Jeremy Allison <jra at samba.org>
Date: Mon Aug 4 13:36:42 2014 -0700
s4: tests: Added local.charset test for Bug 10716 - smbd constantly crashes when filename contains non-ascii character
https://bugzilla.samba.org/show_bug.cgi?id=10716
Signed-off-by: Jeremy Allison <jra at samba.org>
commit dfe8dd87e15bec453c7d3a80c4c707d3f2c7b597
Author: Jeremy Allison <jra at samba.org>
Date: Fri Aug 1 21:38:59 2014 -0700
lib: strings: Fix the behavior of strncasecmp_m_handle() in the face of bad conversions.
When either string has a bad conversion, we fall back to
doing raw ascii byte comparisons using strcasecmp(). This
is wrong - we should fall back to strncasecmp.
The problem is we've already stepped past the character
that failed the conversion, so we're not re-testing those
characters for comparison. This can have the effect of
causing strncasecmp_m_handle() to report that two strings
are identical when they are not, if the failed conversion
takes place at the end of the string.
The correct behavior is to step back to the point of
the string(s) that failed the conversion, and continue
the test from there.
This is a litle trickier than the previous fix, as
it requires converting the incoming n variable from
remaining characters to compare to remaining bytes to
compare.
As bytes are always the smallest character size
(1 byte) then it's safe to convert the remaining
characters to check by decrementing the source string
by the last character length (in bytes) and incrementing
the remaining bytes to scan by the same value, then
calling strncasecmp() with the stepped back strings
remaining.
Signed-off-by: Jeremy Allison <jra at samba.org>
commit 9380478a0b292bcb0c11987a88803a37a064d618
Author: Jeremy Allison <jra at samba.org>
Date: Fri Aug 1 21:29:21 2014 -0700
lib: strings: Fix the behavior of strcasecmp_m_handle() in the face of bad conversions.
When either string has a bad conversion, we fall back to
doing raw ascii byte comparisons using strcasecmp().
The problem is we've already stepped past the character
that failed the conversion, so we're not re-testing those
characters for comparison. This can have the effect of
causing strcasecmp_m_handle() to report that two strings
are identical when they are not, if the failed conversion
takes place at the end of the string.
The correct behavior is to step back to the point of
the string(s) that failed the conversion, and continue
the test from there.
Found by <lev at zadarastorage.com> when investigating bug
10716 - smbd constantly crashes when filename contains non-ascii character.
Given the normal character set of utf-8, and an on
disk filename of ISO-8859-1 of file-é on disk hex
value: 66 69 6c 65 2d e9, an incoming open given the
correct utf8 name of file-é will collide when it
should not.
Fixes:
Bug 10716 - smbd constantly crashes when filename contains non-ascii character
https://bugzilla.samba.org/show_bug.cgi?id=10716
Signed-off-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/util/charset/tests/charset.c | 12 ++++++++++++
lib/util/charset/util_str.c | 37 +++++++++++++++++++++++++------------
source3/locking/posix.c | 6 +-----
3 files changed, 38 insertions(+), 17 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/util/charset/tests/charset.c b/lib/util/charset/tests/charset.c
index 70b6741..a47670e 100644
--- a/lib/util/charset/tests/charset.c
+++ b/lib/util/charset/tests/charset.c
@@ -50,12 +50,18 @@ static bool test_codepoint_cmpi(struct torture_context *tctx)
static bool test_strcasecmp_m(struct torture_context *tctx)
{
+ /* file.{accented e} in iso8859-1 */
+ const char file_iso8859_1[7] = { 0x66, 0x69, 0x6c, 0x65, 0x2d, 0xe9, 0 };
+ /* file.{accented e} in utf8 */
+ const char file_utf8[8] = { 0x66, 0x69, 0x6c, 0x65, 0x2d, 0xc3, 0xa9, 0 };
torture_assert(tctx, strcasecmp_m("foo", "bar") != 0, "different strings");
torture_assert(tctx, strcasecmp_m("foo", "foo") == 0, "same case strings");
torture_assert(tctx, strcasecmp_m("foo", "Foo") == 0, "different case strings");
torture_assert(tctx, strcasecmp_m(NULL, "Foo") != 0, "one NULL");
torture_assert(tctx, strcasecmp_m("foo", NULL) != 0, "other NULL");
torture_assert(tctx, strcasecmp_m(NULL, NULL) == 0, "both NULL");
+ torture_assert(tctx, strcasecmp_m(file_iso8859_1, file_utf8) != 0,
+ "file.{accented e} should differ");
return true;
}
@@ -102,6 +108,10 @@ static bool test_string_replace_m(struct torture_context *tctx)
static bool test_strncasecmp_m(struct torture_context *tctx)
{
+ /* file.{accented e} in iso8859-1 */
+ const char file_iso8859_1[7] = { 0x66, 0x69, 0x6c, 0x65, 0x2d, 0xe9, 0 };
+ /* file.{accented e} in utf8 */
+ const char file_utf8[8] = { 0x66, 0x69, 0x6c, 0x65, 0x2d, 0xc3, 0xa9, 0 };
torture_assert(tctx, strncasecmp_m("foo", "bar", 3) != 0, "different strings");
torture_assert(tctx, strncasecmp_m("foo", "foo", 3) == 0, "same case strings");
torture_assert(tctx, strncasecmp_m("foo", "Foo", 3) == 0, "different case strings");
@@ -111,6 +121,8 @@ static bool test_strncasecmp_m(struct torture_context *tctx)
torture_assert(tctx, strncasecmp_m(NULL, "Foo", 3) != 0, "one NULL");
torture_assert(tctx, strncasecmp_m("foo", NULL, 3) != 0, "other NULL");
torture_assert(tctx, strncasecmp_m(NULL, NULL, 3) == 0, "both NULL");
+ torture_assert(tctx, strncasecmp_m(file_iso8859_1, file_utf8, 6) != 0,
+ "file.{accented e} should differ");
return true;
}
diff --git a/lib/util/charset/util_str.c b/lib/util/charset/util_str.c
index 688ab5a..d2e6cbb 100644
--- a/lib/util/charset/util_str.c
+++ b/lib/util/charset/util_str.c
@@ -47,6 +47,11 @@ _PUBLIC_ int strcasecmp_m_handle(struct smb_iconv_handle *iconv_handle,
c1 = next_codepoint_handle(iconv_handle, s1, &size1);
c2 = next_codepoint_handle(iconv_handle, s2, &size2);
+ if (c1 == INVALID_CODEPOINT ||
+ c2 == INVALID_CODEPOINT) {
+ return strcasecmp(s1, s2);
+ }
+
s1 += size1;
s2 += size2;
@@ -54,12 +59,6 @@ _PUBLIC_ int strcasecmp_m_handle(struct smb_iconv_handle *iconv_handle,
continue;
}
- if (c1 == INVALID_CODEPOINT ||
- c2 == INVALID_CODEPOINT) {
- /* what else can we do?? */
- return strcasecmp(s1, s2);
- }
-
if (toupper_m(c1) != toupper_m(c2)) {
return c1 - c2;
}
@@ -97,6 +96,26 @@ _PUBLIC_ int strncasecmp_m_handle(struct smb_iconv_handle *iconv_handle,
c1 = next_codepoint_handle(iconv_handle, s1, &size1);
c2 = next_codepoint_handle(iconv_handle, s2, &size2);
+ if (c1 == INVALID_CODEPOINT ||
+ c2 == INVALID_CODEPOINT) {
+ /*
+ * n was specified in characters,
+ * now we must convert it to bytes.
+ * As bytes are the smallest
+ * character unit, the following
+ * increment and strncasecmp is always
+ * safe.
+ *
+ * The source string was already known
+ * to be n characters long, so we are
+ * guaranteed to be able to look at the
+ * (n remaining + size1) bytes from the
+ * s1 position).
+ */
+ n += size1;
+ return strncasecmp(s1, s2, n);
+ }
+
s1 += size1;
s2 += size2;
@@ -104,12 +123,6 @@ _PUBLIC_ int strncasecmp_m_handle(struct smb_iconv_handle *iconv_handle,
continue;
}
- if (c1 == INVALID_CODEPOINT ||
- c2 == INVALID_CODEPOINT) {
- /* what else can we do?? */
- return strcasecmp(s1, s2);
- }
-
if (toupper_m(c1) != toupper_m(c2)) {
return c1 - c2;
}
diff --git a/source3/locking/posix.c b/source3/locking/posix.c
index 9ee59be..a0966ab 100644
--- a/source3/locking/posix.c
+++ b/source3/locking/posix.c
@@ -114,7 +114,7 @@ static bool posix_lock_in_range(off_t *offset_out, off_t *count_out,
* any Win32 locks of length zero. JRA.
*/
- if (count == (off_t)0) {
+ if (count == 0) {
DEBUG(10,("posix_lock_in_range: count = 0, ignoring.\n"));
return False;
}
@@ -686,7 +686,6 @@ struct lock_list {
static struct lock_list *posix_lock_list(TALLOC_CTX *ctx,
struct lock_list *lhead,
const struct lock_context *lock_ctx, /* Lock context lhead belongs to. */
- files_struct *fsp,
const struct lock_struct *plocks,
int num_locks)
{
@@ -1004,7 +1003,6 @@ bool set_posix_lock_windows_flavour(files_struct *fsp,
llist = posix_lock_list(l_ctx,
llist,
lock_ctx, /* Lock context llist belongs to. */
- fsp,
plocks,
num_locks);
@@ -1133,7 +1131,6 @@ bool release_posix_lock_windows_flavour(files_struct *fsp,
ulist = posix_lock_list(ul_ctx,
ulist,
lock_ctx, /* Lock context ulist belongs to. */
- fsp,
plocks,
num_locks);
@@ -1293,7 +1290,6 @@ bool release_posix_lock_posix_flavour(files_struct *fsp,
ulist = posix_lock_list(ul_ctx,
ulist,
lock_ctx, /* Lock context ulist belongs to. */
- fsp,
plocks,
num_locks);
--
Samba Shared Repository
More information about the samba-cvs
mailing list