Bug #33868 MySQL Proxy aborts when return proxy.PROXY_SEND_RESULT is sent during handshake
Submitted: 14 Jan 2008 17:12 Modified: 11 May 2008 5:39
Reporter: Alex Chittock Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Proxy: Core Severity:S3 (Non-critical)
Version:0.6.0, 0.6.1, r 369, 0.7.1 OS:Linux (Ubuntu Server 7.10)
Assigned to: Assigned Account CPU Architecture:Any
Tags: handshake network-mysqld-proxy.c.2356
Triage: D2 (Serious)

[14 Jan 2008 17:12] Alex Chittock
Description:
In the tutorial-states.lua script the read_handshake function compares the client address with a predefined address, when this fails it returns proxy.PROXY_SEND_RESULT.

When this occurs the proxy aborts. I've included the full program output.

alex@linux:~$ mysql-proxy --proxy-lua-script=/etc/mysql-proxy/tutorial-states.lua
--> a client really wants to talk to a server
<-- let's send him some information about us
    mysqld-version: 50045
    thread-id     : 48
    scramble-buf  : "[Ri:%J'\"r:h}]9B#'8#E\000"
    server-addr   : 127.0.0.1:3306
    client-addr   : 192.168.1.71:56841
we don't like this client
network-mysqld-proxy.c.2356: ...
Aborted
alex@linux:~$ 

How to repeat:
1. Execute mysql-proxy with the tutorial-states.lua script.
2. Connect to the proxy from a machine that is not specified in the file (anything but localhost)
[11 May 2008 5:39] Sveta Smirnova
Thank you for the report.

Verified as described.
[11 May 2008 5:41] Sveta Smirnova
Bug #36640 was marked as duplicate of this one.

Bug #36640 contains patch and more detailed descriptiona bout cause of the problem.
[25 May 2008 10:59] David Mobe
Suggested fix:
I recommended to fix the code of mysql-proxy-0.6.1\src\network-mysqld-proxy.c from line
2439 to 2453 like this:
switch (proxy_lua_read_handshake(con)) {
	case PROXY_NO_DECISION:
		break;
	case PROXY_SEND_RESULT:
		/* the client overwrote and wants to send its own packet
		 * it is already in the queue */

		recv_sock->packet_len = PACKET_LEN_UNSET;
		g_queue_delete_link(recv_sock->recv_queue->chunks, chunk);

		return RET_ERROR;
	default:
		g_error("proxy_lua_read_handshake return value invalid in %s.%d", __FILE__, __LINE__);
		
		recv_sock->packet_len = PACKET_LEN_UNSET;
		g_queue_delete_link(recv_sock->recv_queue->chunks, chunk);

		return RET_ERROR;
	}
[3 Jun 2009 14:27] Kay Roepke
In the current trunk and release version, the read_handshake and read_auth callbacks no longer receive an argument.
The data is only available through the proxy.connection table.

Regarding the patch included, I haven't checked whether it would still apply yet.