summaryrefslogtreecommitdiff
path: root/sql-common
diff options
context:
space:
mode:
authorGeorgi Kodinov <Georgi.Kodinov@Oracle.com>2012-06-29 16:54:55 +0300
committerGeorgi Kodinov <Georgi.Kodinov@Oracle.com>2012-06-29 16:54:55 +0300
commite65c291807f57b9533df07963b0385cbfdd5b474 (patch)
treee47e30d41c92efb2ee66c520957eae4bdf7b8513 /sql-common
parent66ef5b0d48006263e2ae8eec29fd8900d6708af4 (diff)
parent107c894a540d147338ab4e737eb9ef76e49c3493 (diff)
downloadmariadb-git-e65c291807f57b9533df07963b0385cbfdd5b474.tar.gz
merge bug#13708485 5.1->5.5
Diffstat (limited to 'sql-common')
-rw-r--r--sql-common/client.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/sql-common/client.c b/sql-common/client.c
index a453a1a161f..08f4bfb1151 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1430,7 +1430,7 @@ static void cli_fetch_lengths(ulong *to, MYSQL_ROW column,
***************************************************************************/
MYSQL_FIELD *
-unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
+unpack_fields(MYSQL *mysql, MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
my_bool default_value, uint server_capabilities)
{
MYSQL_ROWS *row;
@@ -1443,6 +1443,7 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
if (!result)
{
free_rows(data); /* Free old data */
+ set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
DBUG_RETURN(0);
}
bzero((char*) field, (uint) sizeof(MYSQL_FIELD)*fields);
@@ -1470,6 +1471,14 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
field->org_name_length= lengths[5];
/* Unpack fixed length parts */
+ if (lengths[6] != 12)
+ {
+ /* malformed packet. signal an error. */
+ free_rows(data); /* Free old data */
+ set_mysql_error(mysql, CR_MALFORMED_PACKET, unknown_sqlstate);
+ DBUG_RETURN(0);
+ }
+
pos= (uchar*) row->data[6];
field->charsetnr= uint2korr(pos);
field->length= (uint) uint4korr(pos+2);
@@ -3815,7 +3824,7 @@ get_info:
if (!(fields=cli_read_rows(mysql,(MYSQL_FIELD*)0, protocol_41(mysql) ? 7:5)))
DBUG_RETURN(1);
- if (!(mysql->fields=unpack_fields(fields,&mysql->field_alloc,
+ if (!(mysql->fields=unpack_fields(mysql, fields,&mysql->field_alloc,
(uint) field_count,0,
mysql->server_capabilities)))
DBUG_RETURN(1);