diff options
author | Guy Harris <guy@alum.mit.edu> | 2019-07-16 16:42:35 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2019-07-17 01:56:01 +0000 |
commit | 81e2d2a668cc06e53168623af19718c03f68ab1d (patch) | |
tree | cf4640f5b27c728799b49ca7349a0f51df938e0a | |
parent | 705942f7963e5f02253b630ebc08d375332fd68d (diff) |
Don't just grab raw string data with tvb_memcpy().
Use tvb_get_string_enc() routines to fetch them; all strings must have
an encoding value, to properly map to UTF-8.
While we're at it, fix heuristic test to make sure we have a full TALI
header in the *captured* data.
Change-Id: Ia572707f8d7da89d3fe31e839e1cbe4dc5e23c43
Reviewed-on: https://code.wireshark.org/review/33980
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r-- | epan/dissectors/packet-tali.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/epan/dissectors/packet-tali.c b/epan/dissectors/packet-tali.c index 364e3a59e2..ee93bbfd39 100644 --- a/epan/dissectors/packet-tali.c +++ b/epan/dissectors/packet-tali.c @@ -84,7 +84,7 @@ get_tali_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _ static int dissect_tali_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { - char opcode[TALI_OPCODE_LENGTH+1]; /* TALI opcode */ + char *opcode; /* TALI opcode */ guint16 length; /* TALI length */ tvbuff_t *payload_tvb = NULL; @@ -92,8 +92,7 @@ dissect_tali_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data proto_item *tali_item = NULL; proto_tree *tali_tree = NULL; - tvb_memcpy(tvb, (guint8*)opcode, TALI_SYNC_LENGTH, TALI_OPCODE_LENGTH); - opcode[TALI_OPCODE_LENGTH] = '\0'; + opcode = (char *) tvb_get_string_enc(wmem_packet_scope(), tvb, TALI_SYNC_LENGTH, TALI_OPCODE_LENGTH, ENC_ASCII|ENC_NA); length = tvb_get_letohs(tvb, TALI_SYNC_LENGTH + TALI_OPCODE_LENGTH); /* Make entries in Protocol column on summary display */ @@ -141,7 +140,14 @@ dissect_tali_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat { char opcode[TALI_OPCODE_LENGTH]; /* TALI opcode */ - if (tvb_reported_length(tvb) < TALI_HEADER_LENGTH) /* Mandatory header */ + /* + * If we don't have at least TALI_HEADER_LENGTH bytes worth of captured + * data (i.e., available to look at), we can't determine whether this + * looks like a TALI packet or not. We must use tvb_captured_length() + * because the data must be present in the capture, not sliced off due + * to the snapshot length specified for the capture. + */ + if (tvb_captured_length(tvb) < TALI_HEADER_LENGTH) /* Mandatory header */ return FALSE; if (tvb_strneql(tvb, 0, TALI_SYNC, TALI_SYNC_LENGTH) != 0) |