packet-cql: keys with length -1 are NULL values

When procssing results, Wireshark did not properly handled keys with length -1, which actually means NULL.
This fixes it (and as a results, parses properly some result packets it failed to parse properly before).

Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>
This commit is contained in:
Yaniv Kaul 2023-01-01 11:53:47 +02:00 committed by AndersBroman
parent cffdb5945e
commit 140ebf5829
1 changed files with 10 additions and 7 deletions

View File

@ -959,6 +959,7 @@ dissect_cql_tcp_pdu(tvbuff_t* raw_tvb, packet_info* pinfo, proto_tree* tree, voi
gint32 result_rows_columns_count = 0;
gint64 j = 0;
gint64 k = 0;
guint32 short_bytes_length = 0;
gint32 bytes_length = 0;
gint32 result_rows_row_count = 0;
@ -1221,10 +1222,10 @@ dissect_cql_tcp_pdu(tvbuff_t* raw_tvb, packet_info* pinfo, proto_tree* tree, voi
/* TODO: link to original PREPARE? */
/* Query ID */
proto_tree_add_item_ret_uint(cql_subtree, hf_cql_short_bytes_length, tvb, offset, 2, ENC_BIG_ENDIAN, &bytes_length);
proto_tree_add_item_ret_uint(cql_subtree, hf_cql_short_bytes_length, tvb, offset, 2, ENC_BIG_ENDIAN, &short_bytes_length);
offset += 2;
proto_tree_add_item(cql_subtree, hf_cql_query_id, tvb, offset, bytes_length, ENC_NA);
offset += bytes_length;
proto_tree_add_item(cql_subtree, hf_cql_query_id, tvb, offset, short_bytes_length, ENC_NA);
offset += short_bytes_length;
/* Query parameters */
dissect_cql_query_parameters(cql_subtree, tvb, offset, 1);
@ -1445,8 +1446,10 @@ dissect_cql_tcp_pdu(tvbuff_t* raw_tvb, packet_info* pinfo, proto_tree* tree, voi
for (k = 0; k < result_rows_columns_count; ++k) {
proto_tree_add_item_ret_int(columns_subtree, hf_cql_bytes_length, tvb, offset, 4, ENC_BIG_ENDIAN, &bytes_length);
offset += 4;
proto_tree_add_item(columns_subtree, hf_cql_bytes, tvb, offset, bytes_length, ENC_NA);
offset += bytes_length;
if (bytes_length > 0) {
proto_tree_add_item(columns_subtree, hf_cql_bytes, tvb, offset, bytes_length, ENC_NA);
offset += bytes_length;
}
}
}
}
@ -1464,9 +1467,9 @@ dissect_cql_tcp_pdu(tvbuff_t* raw_tvb, packet_info* pinfo, proto_tree* tree, voi
case CQL_RESULT_KIND_PREPARED:
/* Query ID */
proto_tree_add_item_ret_uint(cql_subtree, hf_cql_short_bytes_length, tvb, offset, 2, ENC_BIG_ENDIAN, &bytes_length);
proto_tree_add_item_ret_uint(cql_subtree, hf_cql_short_bytes_length, tvb, offset, 2, ENC_BIG_ENDIAN, &short_bytes_length);
offset += 2;
proto_tree_add_item(cql_subtree, hf_cql_query_id, tvb, offset, bytes_length, ENC_NA);
proto_tree_add_item(cql_subtree, hf_cql_query_id, tvb, offset, short_bytes_length, ENC_NA);
break;