diff options
author | unknown <peter@mysql.com> | 2002-12-05 03:55:29 +0300 |
---|---|---|
committer | unknown <peter@mysql.com> | 2002-12-05 03:55:29 +0300 |
commit | 339cf7ce7bc856996812786f95dfa9f8717d3b99 (patch) | |
tree | 0d1d28ba46e738e0d01fff771cd505a057e5d664 /libmysql | |
parent | d318b4b857c2c8312842ec132aad786ce165138f (diff) | |
download | mariadb-git-339cf7ce7bc856996812786f95dfa9f8717d3b99.tar.gz |
Basically minor code optimizations and cleanups
client/mysqladmin.c:
fix folding
libmysql/libmysql.c:
Minor optimizations
sql/mini_client.cc:
Minor optimizations
sql/password.c:
Optimiations
sql/sql_acl.cc:
Get rid of stage parameter and flag old passwords with '*' instead of zero
sql/sql_acl.h:
fix prototype
sql/sql_parse.cc:
Minor optimizations
Diffstat (limited to 'libmysql')
-rw-r--r-- | libmysql/libmysql.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 842e8fe845d..7a5fcb8c6b7 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2228,9 +2228,12 @@ Try also with PIPE or TCP/IP { if (passwd[0]) { - /* Use something for not empty password not to match against empty one */ - end=scramble(strend(buff+5)+1, mysql->scramble_buff,"\1~MySQL#!\2", - (my_bool) (mysql->protocol_version == 9)); + /* Prepare false scramble */ + end=strend(buff+5)+1; + bfill(end, SCRAMBLE_LENGTH, 'x'); + end+=SCRAMBLE_LENGTH; + *end=0; + end++; } else /* For empty password*/ { @@ -2238,8 +2241,11 @@ Try also with PIPE or TCP/IP *end=0; /* Store zero length scramble */ } } - /* Real scramble is sent only for servers. This is to be blocked by option */ else + /* + Real scramble is only sent to old servers. This can be blocked + by calling mysql_options(MYSQL *, MYSQL_SECURE_CONNECT, (char*) &1); + */ end=scramble(strend(buff+5)+1, mysql->scramble_buff, passwd, (my_bool) (mysql->protocol_version == 9)); @@ -2265,11 +2271,12 @@ Try also with PIPE or TCP/IP if (mysql->server_capabilities & CLIENT_SECURE_CONNECTION) { - /* This should basically always happen with new server unless empty password */ - if (pkt_length==24) /* We have new hash back */ + /* This should always happen with new server unless empty password */ + if (pkt_length==24 && net->read_pos[0]) + /* OK/Error packets have zero as the first char */ { - /* Old passwords will have zero at the first byte of hash */ - if (net->read_pos[0]) + /* Old passwords will have '*' at the first byte of hash */ + if (net->read_pos[0] != '*') { /* Build full password hash as it is required to decode scramble */ password_hash_stage1(buff, passwd); @@ -2433,15 +2440,20 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, { if (passwd[0]) { - /* Use something for not empty password not to match it against empty one */ - end=scramble(end, mysql->scramble_buff,"\1~MySQL#!\2", - (my_bool) (mysql->protocol_version == 9)); + /* Prepare false scramble */ + bfill(end, SCRAMBLE_LENGTH, 'x'); + end+=SCRAMBLE_LENGTH; + *end=0; + } else /* For empty password*/ *end=0; /* Store zero length scramble */ } - /* Real scramble is sent only for servers. This is to be blocked by option */ else + /* + Real scramble is only sent to old servers. This can be blocked + by calling mysql_options(MYSQL *, MYSQL_SECURE_CONNECT, (char*) &1); + */ end=scramble(end, mysql->scramble_buff, passwd, (my_bool) (mysql->protocol_version == 9)); @@ -2458,11 +2470,12 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, if (mysql->server_capabilities & CLIENT_SECURE_CONNECTION) { - /* This should basically always happen with new server unless empty password */ - if (pkt_length==24) /* We have new hash back */ + /* This should always happen with new server unless empty password */ + if (pkt_length==24 && net->read_pos[0]) + /* Err/OK messages has first character=0 */ { /* Old passwords will have zero at the first byte of hash */ - if (net->read_pos[0]) + if (net->read_pos[0] != '*') { /* Build full password hash as it is required to decode scramble */ password_hash_stage1(buff, passwd); |