Bug #4998 --protocol doesn't reject bad values
Submitted: 11 Aug 2004 18:40 Modified: 24 Aug 2004 14:48
Reporter: Paul Dubois Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:4.1.X OS:Any (Any)
Assigned to: Bugs System CPU Architecture:Any

[11 Aug 2004 18:40] Paul Dubois
Description:
No error results if you specify the --protocol client
option with a bad protocol type. You end up with
a type of connection you didn't request.

How to repeat:
% mysql --protocol=type-anything-you-want-here
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8 to server version: 4.1.4-beta-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
[11 Aug 2004 18:49] Matthew Lord
I could not verify this on windows:

E:\MySQL\odbc>mysql -u root -p --protocol=http
mysql: ERROR: unknown variable 'protocol=http'

However on x86 linux (RH 9,  2.4.21 #12 SMP) I could:

booty-[~]$mysql -p --protocol=http
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.

We should produce the same error I get when I try to use --protocol=pipe on linux:
ERROR 2047 (HY000): Wrong or unknown protocol
[11 Aug 2004 18:50] Matthew Lord
Sorry,

I was using windows 2000 to be more specific.  Both machines were connecting to 4.1.3-beta 
locally.
[11 Aug 2004 20:03] Matthew Lord
Correction.  The same behavior exhibits itself on windows 2000 as well as x86 linux.

I was in a hurry and I didn't look closely at the error to notice that I was using the 4.0.20
client to connect to 4.1.3.  I just noticed it in the email from the bugs db.

I apologize.
[11 Aug 2004 21:33] Guilhem Bichot
Had noticed that issue some weeks ago. Problem is:
  {
    if ((opt_protocol = find_type(argument, &sql_protocol_typelib,0)) == ~(ulong) 0)
    {
      fprintf(stderr, "Unknown option to protocol: %s\n", argument);
      exit(1);
    }
    break;
  }
find_type() returns -1 if at least 2 matches, 0 if no match, and >0 if one match.
Whereas the code above only tests for -1. Problem is in mysql.cc, mysqladmin.c etc.
[23 Aug 2004 15:24] Victor Vagin
bk commit into 4.1 tree (vva:1.1963)

ChangeSet
  1.1963 04/08/23 20:55:09 vva@eagle.mysql.r18.ru +9 -0
  fixed a Bug #4998 "--protocol doesn't reject bad values"
[24 Aug 2004 14:48] Victor Vagin
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

The fix will be in the mysql-4.1.4