Wireshark-dev: [Wireshark-dev] [PATCH] MySQL decode OK-Packet improvement
From: Martin Warnes <[email protected]>
Date: Sun, 10 Jun 2007 19:16:29 +0100
Currently the MySQL dissector assumes that an OK-Packet Response contains the Server_Status field. Having checked the MySQL protocol page I can't say conclusively whether it should or it shouldn't, however I've come across a couple of MySQL Java clients that receive the OK-Packet without the Server_Status field set in response to a "SET AUTOCOMMIT" call.
The attached patched simply adds a check to ensure the Server_Status 
field is present before calling function mysql_dissect_server_status.
Regards .. Martin
Index: packet-mysql.c
===================================================================
--- packet-mysql.c	(revision 22068)
+++ packet-mysql.c	(working copy)
@@ -1687,15 +1687,17 @@
 	}
 	offset+= fle;
 
-	offset= mysql_dissect_server_status(tvb, offset, tree);
+	if ((strlen= tvb_length_remaining(tvb, offset))) {
+	        offset= mysql_dissect_server_status(tvb, offset, tree);
 
-	/* 4.1+ protocol only: 2 bytes number of warnings */
-	if (conn_data->clnt_caps & conn_data->srv_caps & MYSQL_CAPS_CU) {
-		if (tree) {
-			proto_tree_add_item(tree, hf_mysql_num_warn, tvb,
-					    offset, 2, FALSE);
+	        /* 4.1+ protocol only: 2 bytes number of warnings */
+		if (conn_data->clnt_caps & conn_data->srv_caps & MYSQL_CAPS_CU) {
+		        if (tree) {
+			        proto_tree_add_item(tree, hf_mysql_num_warn, tvb,
+				         	    offset, 2, FALSE);
+		        }
+		offset+= 2;
 		}
-		offset+= 2;
 	}
 
 	/* optional: message string */