summaryrefslogtreecommitdiff
path: root/sql/sql_yacc.yy
diff options
context:
space:
mode:
authorSujatha Sivakumar <sujatha.sivakumar@oracle.com>2013-06-24 11:11:55 +0530
committerSujatha Sivakumar <sujatha.sivakumar@oracle.com>2013-06-24 11:11:55 +0530
commit318077c4f9d57e106eecd15c5e84ffeacbc799c5 (patch)
tree6903cecda6ac84e4287ab67b6ee2396aa71422f6 /sql/sql_yacc.yy
parenta326f9747b60d3726c09ee4979ae8782b8406237 (diff)
downloadmariadb-git-318077c4f9d57e106eecd15c5e84ffeacbc799c5.tar.gz
Bug#16753869:INCORRECT TRUNCATION OF LONG SET EXPRESSION IN
LOAD DATA CAN CAUSE SQL INJECTION Problem: ======= A long SET expression in LOAD DATA is incorrectly truncated when written to the binary log. Analysis: ======== LOAD DATA statements are reconstructed once again before they are written to the binary log. When SET clauses are specified as part of LOAD DATA statement, these SET clause user command strings need to be stored as it is inorder to reconstruct the original user command. At present these strings are stored as part of SET clause item tree's top most Item node's name itself which is incorrect. As an Item::name can be of MAX_ALIAS_NAME (256) size. Hence the name will get truncated to "255". Because of this the rewritten LOAD DATA statement will be terminated incorrectly. When this statment is read back by the mysqlbinlog tool it reads a starting single quote and continuos to read till it finds an ending quote. Hence any statement written post ending quote will be considered as a new statement. Fix: === As name field has length restriction the string value should not be stored in Item::name. A new String list is maintained to store the SET expression values and this list is read during reconstrution.
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r--sql/sql_yacc.yy13
1 files changed, 10 insertions, 3 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 5ab7ae4a674..13c547cb9f7 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -11727,10 +11727,17 @@ load_data_set_elem:
simple_ident_nospvar equal remember_name expr_or_default remember_end
{
LEX *lex= Lex;
- if (lex->update_list.push_back($1) ||
- lex->value_list.push_back($4))
+ uint length= (uint) ($5 - $3);
+ String *val= new (YYTHD->mem_root) String($3,
+ length,
+ YYTHD->charset());
+ if (val == NULL)
+ MYSQL_YYABORT;
+ if (lex->update_list.push_back($1) ||
+ lex->value_list.push_back($4) ||
+ lex->load_set_str_list.push_back(val))
MYSQL_YYABORT;
- $4->set_name($3, (uint) ($5 - $3), YYTHD->charset());
+ $4->set_name($3, length, YYTHD->charset());
}
;