Skip to content

Commit b21a021

Browse files
author
Ajo Robert
committed
Bug#23195404 EXCESSIVE MEMORY CAN BE USED BY THE QUOTE()
STRING FUNCTION Fix: ======= Added code in QUOTE string function to honor max_allowed_packet.
1 parent 7ec26b0 commit b21a021

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

sql/item_strfunc.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -3649,6 +3649,17 @@ String *Item_func_quote::val_str(String *str)
36493649
*to= '\'';
36503650

36513651
ret:
3652+
if (new_length > current_thd->variables.max_allowed_packet)
3653+
{
3654+
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
3655+
ER_WARN_ALLOWED_PACKET_OVERFLOWED,
3656+
ER_THD(current_thd, ER_WARN_ALLOWED_PACKET_OVERFLOWED),
3657+
func_name(),
3658+
current_thd->variables.max_allowed_packet);
3659+
null_value= true;
3660+
return NULL;
3661+
}
3662+
36523663
tmp_value.length(new_length);
36533664
tmp_value.set_charset(collation.collation);
36543665
null_value= 0;

0 commit comments

Comments
 (0)