Skip to content

Commit bcbce34

Browse files
committed
auto-merge
2 parents 5ba700c + 405f7ca commit bcbce34

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

mysql-test/r/cast.result

+15
Original file line numberDiff line numberDiff line change
@@ -451,4 +451,19 @@ SELECT CONVERT(t2.a USING UTF8) FROM t1, t1 t2 LIMIT 1
451451
1
452452
1
453453
DROP TABLE t1;
454+
#
455+
# Bug #11765023: 57934: DOS POSSIBLE SINCE BINARY CASTING
456+
# DOESN'T ADHERE TO MAX_ALLOWED_PACKET
457+
SET @@GLOBAL.max_allowed_packet=2048;
458+
SELECT CONVERT('a', BINARY(2049));
459+
CONVERT('a', BINARY(2049))
460+
NULL
461+
Warnings:
462+
Warning 1301 Result of cast_as_binary() was larger than max_allowed_packet (2048) - truncated
463+
SELECT CONVERT('a', CHAR(2049));
464+
CONVERT('a', CHAR(2049))
465+
NULL
466+
Warnings:
467+
Warning 1301 Result of cast_as_char() was larger than max_allowed_packet (2048) - truncated
468+
SET @@GLOBAL.max_allowed_packet=default;
454469
End of 5.1 tests

mysql-test/t/cast.test

+14
Original file line numberDiff line numberDiff line change
@@ -280,5 +280,19 @@ SELECT 1 FROM
280280
) AS s LIMIT 1;
281281
DROP TABLE t1;
282282

283+
--echo #
284+
--echo # Bug #11765023: 57934: DOS POSSIBLE SINCE BINARY CASTING
285+
--echo # DOESN'T ADHERE TO MAX_ALLOWED_PACKET
286+
287+
SET @@GLOBAL.max_allowed_packet=2048;
288+
# reconnect to make the new max packet size take effect
289+
--connect (newconn, localhost, root,,)
290+
291+
SELECT CONVERT('a', BINARY(2049));
292+
SELECT CONVERT('a', CHAR(2049));
293+
294+
connection default;
295+
disconnect newconn;
296+
SET @@GLOBAL.max_allowed_packet=default;
283297

284298
--echo End of 5.1 tests

sql/item_timefunc.cc

+13
Original file line numberDiff line numberDiff line change
@@ -2524,6 +2524,19 @@ String *Item_char_typecast::val_str(String *str)
25242524
String *res;
25252525
uint32 length;
25262526

2527+
if (cast_length >= 0 &&
2528+
((unsigned) cast_length) > current_thd->variables.max_allowed_packet)
2529+
{
2530+
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
2531+
ER_WARN_ALLOWED_PACKET_OVERFLOWED,
2532+
ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED),
2533+
cast_cs == &my_charset_bin ?
2534+
"cast_as_binary" : func_name(),
2535+
current_thd->variables.max_allowed_packet);
2536+
null_value= 1;
2537+
return 0;
2538+
}
2539+
25272540
if (!charset_conversion)
25282541
{
25292542
if (!(res= args[0]->val_str(str)))

0 commit comments

Comments
 (0)