Bug #43313 proxy.connection.client.address contains a wrong port number
Submitted: 2 Mar 2009 22:30 Modified: 17 Aug 2009 15:19
Reporter: Jan Kneschke Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Proxy: Core Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: MC Brown CPU Architecture:Any

[2 Mar 2009 22:30] Jan Kneschke
Description:
proxy.connection.client.address contains the wrong src-port number

How to repeat:
function connect_server()
  print(proxy.connection.client.address)
end

... and compare the output with "netstat -a" for that connection.

(we miss a ntohs() in network_address_resolve_address())

Suggested fix:
=== modified file 'src/network-socket.c'
--- src/network-socket.c        2009-03-02 22:18:30 +0000
+++ src/network-socket.c        2009-03-02 22:27:56 +0000
@@ -799,7 +799,7 @@
        case AF_INET:
                addr->str = g_strdup_printf("%s:%d", 
                                inet_ntoa(addr->addr.ipv4.sin_addr),
-                               addr->addr.ipv4.sin_port);
+                               ntohs(addr->addr.ipv4.sin_port));
                break;
 #ifdef AF_UNIX
        case AF_UNIX:
[2 Mar 2009 22:32] Jan Kneschke
Patch and test-case have been committed:

revno: 1213
committer: jan@mysql.com
branch nick: trunk
timestamp: Mon 2009-03-02 23:30:55 +0100
message:
  fixed missing ntohs() around _resolve_address() (fixes #43313)
[2 Mar 2009 22:54] Jan Kneschke
Committed and pushed to rel-2.0 (and trunk)

revno: 1223
committer: jan@mysql.com
branch nick: rel-2.0
timestamp: Mon 2009-03-02 23:51:24 +0100
message:
  fixed missing ntohs() around _resolve_address() (fixes #43313)
[4 Jun 2009 12:49] Kay Roepke
also committed to proxy bzr trunk
[11 Jun 2009 17:40] Diego Medina
Verified fixed on 0.7.1

Note that you need to use

function connect_server()
  print(proxy.connection.client.src.port)
end

because proxy.connection.client.address is not used any more.
[17 Aug 2009 15:19] MC Brown
A not has been added to the 0.7.1 changelog: 

The port number reported in proxy.connection.client.address would be reported incorrectly