summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-07-08 00:13:24 +0200
committerSergei Golubchik <sergii@pisem.net>2011-07-08 00:13:24 +0200
commit7e518f836045b3baeed6c631c730253575044f7a (patch)
tree8a26276793ee7d89a9f1b28f985b8e5c01d5d137 /sql
parent46465327e796e6c3d9a89dcfb9ba71561fafdb05 (diff)
downloadmariadb-git-7e518f836045b3baeed6c631c730253575044f7a.tar.gz
protocol safety fix:
before strlen(db) we need to be sure that db lies within packet boundaries. same for client_plugin.
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_acl.cc21
1 files changed, 7 insertions, 14 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index f783375b010..5eda8202f73 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -7565,21 +7565,15 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ?
(uchar)(*passwd++) : strlen(passwd);
- if (thd->client_capabilities & CLIENT_CONNECT_WITH_DB)
- {
- db= db + passwd_len + 1;
- /* strlen() can't be easily deleted without changing protocol */
- db_len= strlen(db);
- }
- else
- {
- db= 0;
- db_len= 0;
- }
+ db= thd->client_capabilities & CLIENT_CONNECT_WITH_DB ?
+ db + passwd_len + 1 : 0;
- if (passwd + passwd_len + db_len > (char *)net->read_pos + pkt_len)
+ if (passwd + passwd_len + test(db) > (char *)net->read_pos + pkt_len)
return packet_error;
+ /* strlen() can't be easily deleted without changing protocol */
+ db_len= db ? strlen(db) : 0;
+
char *client_plugin= passwd + passwd_len + (db ? db_len + 1 : 0);
/* Since 4.1 all database names are stored in utf8 */
@@ -7646,8 +7640,7 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
if (thd->client_capabilities & CLIENT_PLUGIN_AUTH)
{
- if ((client_plugin + strlen(client_plugin)) >
- (char *)net->read_pos + pkt_len)
+ if (client_plugin >= (char *)net->read_pos + pkt_len)
return packet_error;
client_plugin= fix_plugin_ptr(client_plugin);
}