From Pierre-Marie de Rodat: PostgreSQL Startup message not properly supported by the PostgreSQL dissector.

"The PostgreSQL dissector do not fully support the frontend StartupMessage (see
"StartupMessage" in
http://developer.postgresql.org/pgdocs/postgres/protocol-message-formats.html).
The couples parameter name/parameter value in this kind of message are reported
as a block of text ("name: value") by the dissector whereas reporting them as
parameter name/parameter value would be more appropriate.

I've fixed it, so now the username and the database sent by the frontend can be
handled in, for instance, the CSV output of TShark.

I've also added a "val_count" field to contain the number of values (row
descriptions or row data) included in RowDescription/DataRow messages. This
information is useful when analyzing the CSV of TShark since in a CSV row, many
row descriptions or row data may be packed together."


Patch changes from me:
- No need to fetch ephemeral string anymore so just use tvb_strsize()
  to get string length;
- Change field-filtername from pgsql.val.count to pgsql.field.count

See: https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6343


svn path=/trunk/; revision=39030
This commit is contained in:
Bill Meier 2011-09-16 20:08:46 +00:00
parent afb6549467
commit 3f3bb6b95a
1 changed files with 12 additions and 6 deletions

View File

@ -60,6 +60,7 @@ static int hf_tableoid = -1;
static int hf_typeoid = -1;
static int hf_oid = -1;
static int hf_format = -1;
static int hf_field_count = -1;
static int hf_val_name = -1;
static int hf_val_idx = -1;
static int hf_val_length = -1;
@ -286,7 +287,7 @@ static void dissect_pgsql_fe_msg(guchar type, guint length, tvbuff_t *tvb,
{
guchar c;
gint i, l;
char *s, *t;
char *s;
proto_item *ti, *hidden_item;
proto_tree *shrub;
@ -412,13 +413,14 @@ static void dissect_pgsql_fe_msg(guchar type, guint length, tvbuff_t *tvb,
/* Startup message */
case 196608:
while (length > 0) {
s = tvb_get_ephemeral_stringz(tvb, n, &l);
l = tvb_strsize(tvb, n);
length -= l;
if (length <= 0) {
break;
}
t = tvb_get_ephemeral_stringz(tvb, n+l, &i);
proto_tree_add_text(tree, tvb, n, l+i, "%s: %s", s, t);
proto_tree_add_item(tree, hf_parameter_name, tvb, n, l, ENC_NA);
i = tvb_strsize(tvb, n+l);
proto_tree_add_item(tree, hf_parameter_value, tvb, n + l, i, ENC_NA);
n += l+i;
length -= i;
if (length == 1 && tvb_get_guint8(tvb, n) == 0)
@ -539,7 +541,7 @@ static void dissect_pgsql_be_msg(guchar type, guint length, tvbuff_t *tvb,
/* Row description */
case 'T':
i = tvb_get_ntohs(tvb, n);
ti = proto_tree_add_text(tree, tvb, n, 2, "Columns: %d", i);
ti = proto_tree_add_item(tree, hf_field_count, tvb, n, 2, FALSE);
shrub = proto_item_add_subtree(ti, ett_values);
n += 2;
while (i-- > 0) {
@ -566,7 +568,7 @@ static void dissect_pgsql_be_msg(guchar type, guint length, tvbuff_t *tvb,
/* Data row */
case 'D':
i = tvb_get_ntohs(tvb, n);
ti = proto_tree_add_text(tree, tvb, n, 2, "Columns: %d", i);
ti = proto_tree_add_item(tree, hf_field_count, tvb, n, 2, FALSE);
shrub = proto_item_add_subtree(ti, ett_values);
n += 2;
while (i-- > 0) {
@ -764,6 +766,10 @@ proto_register_pgsql(void)
{ "Format", "pgsql.format", FT_UINT16, BASE_DEC, VALS(format_vals),
0, "A format specifier.", HFILL }
},
{ &hf_field_count,
{ "Field count", "pgsql.field.count", FT_UINT16, BASE_DEC, NULL, 0,
"The number of fields within a row.", HFILL }
},
{ &hf_val_name,
{ "Column name", "pgsql.col.name", FT_STRINGZ, BASE_NONE, NULL, 0,
"The name of a column.", HFILL }