View | Details | Raw Unified | Return to bug 36162 | Differences between
and this patch

Collapse All | Expand All

(-)a/lib/util/charset/util_str.c (-3 / +11 lines)
 Lines 56-62   _PUBLIC_ int strcasecmp_m_handle(struct smb_iconv_handle *iconv_handle, Link Here 
56
56
57
		if (c1 == INVALID_CODEPOINT ||
57
		if (c1 == INVALID_CODEPOINT ||
58
		    c2 == INVALID_CODEPOINT) {
58
		    c2 == INVALID_CODEPOINT) {
59
			/* what else can we do?? */
59
			/*
60
			 * Fall back to byte
61
			 * comparison. We must
62
			 * step back by the codepoint
63
			 * length we just incremented
64
			 * - otherwise we are not
65
			 * checking the bytes that
66
			 * failed the conversion.
67
			 */
68
			s1 -= size1;
69
			s2 -= size2;
60
			return strcasecmp(s1, s2);
70
			return strcasecmp(s1, s2);
61
		}
71
		}
62
72
63
- 
64
--
65
lib/util/charset/util_str.c |   29 +++++++++++++++++++++++++++--
73
lib/util/charset/util_str.c |   29 +++++++++++++++++++++++++++--
66
1 files changed, 27 insertions(+), 2 deletions(-)
74
1 files changed, 27 insertions(+), 2 deletions(-)
(-)a/lib/util/charset/util_str.c (-4 / +27 lines)
 Lines 116-123   _PUBLIC_ int strncasecmp_m_handle(struct smb_iconv_handle *iconv_handle, Link Here 
116
116
117
		if (c1 == INVALID_CODEPOINT ||
117
		if (c1 == INVALID_CODEPOINT ||
118
		    c2 == INVALID_CODEPOINT) {
118
		    c2 == INVALID_CODEPOINT) {
119
			/* what else can we do?? */
119
			/*
120
			return strcasecmp(s1, s2);
120
			 * Fall back to byte
121
			 * comparison. We must
122
			 * step back by the codepoint
123
			 * length we just incremented
124
			 * by - otherwise we are not
125
			 * checking the bytes that
126
			 * failed the conversion.
127
			 */
128
			s1 -= size1;
129
			s2 -= size2;
130
			/*
131
			 * n was specified in characters,
132
			 * now we must convert it to bytes.
133
			 * As bytes are the smallest
134
			 * character unit, the following
135
			 * increment and strncasecmp is always
136
			 * safe.
137
			 *
138
			 * The source string was already known
139
			 * to be n characters long, so we are
140
			 * guaranteed to be able to look at the
141
			 * (n remaining + size1) bytes from the
142
			 * new (s1 - size1) position).
143
			 */
144
			n += size1;
145
			return strncasecmp(s1, s2, n);
121
		}
146
		}
122
147
123
		if (toupper_m(c1) != toupper_m(c2)) {
148
		if (toupper_m(c1) != toupper_m(c2)) {
124
- 
125
--
126
lib/util/charset/tests/charset.c |   12 ++++++++++++
149
lib/util/charset/tests/charset.c |   12 ++++++++++++
127
1 files changed, 12 insertions(+), 0 deletions(-)
150
1 files changed, 12 insertions(+), 0 deletions(-)
(-)a/lib/util/charset/tests/charset.c (-1 / +12 lines)
 Lines 50-61   static bool test_codepoint_cmpi(struct torture_context *tctx) Link Here 
50
50
51
static bool test_strcasecmp_m(struct torture_context *tctx)
51
static bool test_strcasecmp_m(struct torture_context *tctx)
52
{
52
{
53
	/* file.{accented e} in iso8859-1 */
54
	const char file_iso8859_1[7] = { 0x66, 0x69, 0x6c, 0x65, 0x2d, 0xe9, 0 };
55
	/* file.{accented e} in utf8 */
56
	const char file_utf8[8] =      { 0x66, 0x69, 0x6c, 0x65, 0x2d, 0xc3, 0xa9, 0 };
53
	torture_assert(tctx, strcasecmp_m("foo", "bar") != 0, "different strings");
57
	torture_assert(tctx, strcasecmp_m("foo", "bar") != 0, "different strings");
54
	torture_assert(tctx, strcasecmp_m("foo", "foo") == 0, "same case strings");
58
	torture_assert(tctx, strcasecmp_m("foo", "foo") == 0, "same case strings");
55
	torture_assert(tctx, strcasecmp_m("foo", "Foo") == 0, "different case strings");
59
	torture_assert(tctx, strcasecmp_m("foo", "Foo") == 0, "different case strings");
56
	torture_assert(tctx, strcasecmp_m(NULL, "Foo") != 0, "one NULL");
60
	torture_assert(tctx, strcasecmp_m(NULL, "Foo") != 0, "one NULL");
57
	torture_assert(tctx, strcasecmp_m("foo", NULL) != 0, "other NULL");
61
	torture_assert(tctx, strcasecmp_m("foo", NULL) != 0, "other NULL");
58
	torture_assert(tctx, strcasecmp_m(NULL, NULL) == 0, "both NULL");
62
	torture_assert(tctx, strcasecmp_m(NULL, NULL) == 0, "both NULL");
63
	torture_assert(tctx, strcasecmp_m(file_iso8859_1, file_utf8) != 0,
64
		"file.{accented e} should differ");
59
	return true;
65
	return true;
60
}
66
}
61
67
 Lines 102-107   static bool test_string_replace_m(struct torture_context *tctx) Link Here 
102
108
103
static bool test_strncasecmp_m(struct torture_context *tctx)
109
static bool test_strncasecmp_m(struct torture_context *tctx)
104
{
110
{
111
	/* file.{accented e} in iso8859-1 */
112
	const char file_iso8859_1[7] = { 0x66, 0x69, 0x6c, 0x65, 0x2d, 0xe9, 0 };
113
	/* file.{accented e} in utf8 */
114
	const char file_utf8[8] =      { 0x66, 0x69, 0x6c, 0x65, 0x2d, 0xc3, 0xa9, 0 };
105
	torture_assert(tctx, strncasecmp_m("foo", "bar", 3) != 0, "different strings");
115
	torture_assert(tctx, strncasecmp_m("foo", "bar", 3) != 0, "different strings");
106
	torture_assert(tctx, strncasecmp_m("foo", "foo", 3) == 0, "same case strings");
116
	torture_assert(tctx, strncasecmp_m("foo", "foo", 3) == 0, "same case strings");
107
	torture_assert(tctx, strncasecmp_m("foo", "Foo", 3) == 0, "different case strings");
117
	torture_assert(tctx, strncasecmp_m("foo", "Foo", 3) == 0, "different case strings");
 Lines 111-116   static bool test_strncasecmp_m(struct torture_context *tctx) Link Here 
111
	torture_assert(tctx, strncasecmp_m(NULL, "Foo", 3) != 0, "one NULL");
121
	torture_assert(tctx, strncasecmp_m(NULL, "Foo", 3) != 0, "one NULL");
112
	torture_assert(tctx, strncasecmp_m("foo", NULL, 3) != 0, "other NULL");
122
	torture_assert(tctx, strncasecmp_m("foo", NULL, 3) != 0, "other NULL");
113
	torture_assert(tctx, strncasecmp_m(NULL, NULL, 3) == 0, "both NULL");
123
	torture_assert(tctx, strncasecmp_m(NULL, NULL, 3) == 0, "both NULL");
124
	torture_assert(tctx, strncasecmp_m(file_iso8859_1, file_utf8, 6) != 0,
125
		"file.{accented e} should differ");
114
	return true;
126
	return true;
115
}
127
}
116
128
117
- 

Return to bug 36162