From a58dd11ba08a674e58f07ec5be5f5f339f5d33e0 Mon Sep 17 00:00:00 2001 From: Anders Broman Date: Fri, 11 Jan 2019 14:13:25 +0100 Subject: [PATCH] nettrace: Fix missing tag length for IPV4_DST. Change-Id: I00564adaef2922ff991887f0ee5c04a3c7307019 Reviewed-on: https://code.wireshark.org/review/31488 Petri-Dish: Anders Broman Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- wiretap/nettrace_3gpp_32_423.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/wiretap/nettrace_3gpp_32_423.c b/wiretap/nettrace_3gpp_32_423.c index 2cfd3b1f0a..9f1c570ad7 100644 --- a/wiretap/nettrace_3gpp_32_423.c +++ b/wiretap/nettrace_3gpp_32_423.c @@ -352,7 +352,6 @@ write_packet_data(wtap_dumper *wdh, wtap_rec *rec, int *err, gchar **err_info, g int tag_str_len = 0; int proto_str_len, dissector_table_str_len, raw_data_len, pkt_data_len, exp_pdu_tags_len, i, j; guint8 *packet_buf; - gchar chr; gint val1, val2; gboolean port_type_defined = FALSE; gboolean use_proto_table = FALSE; @@ -411,7 +410,7 @@ write_packet_data(wtap_dumper *wdh, wtap_rec *rec, int *err, gchar **err_info, g } /* Find the start of the raw data*/ curr_pos = strstr(next_pos, ">") + 1; - next_pos = strstr(next_pos, "<"); + next_pos = strstr(curr_pos, "<"); raw_data_len = (int)(next_pos - curr_pos); @@ -589,6 +588,8 @@ write_packet_data(wtap_dumper *wdh, wtap_rec *rec, int *err, gchar **err_info, g i++; packet_buf[i] = 0; i++; + packet_buf[i] = EXP_PDU_TAG_IPV4_DST_LEN; /* tag length */; + i++; memcpy(packet_buf + i, exported_pdu_info->dst_ip, EXP_PDU_TAG_IPV4_DST_LEN); i += EXP_PDU_TAG_IPV4_DST_LEN; } @@ -656,17 +657,23 @@ write_packet_data(wtap_dumper *wdh, wtap_rec *rec, int *err, gchar **err_info, g /* Convert the hex raw msg data to binary and write to the packet buf*/ for (; i < (pkt_data_len + exp_pdu_tags_len); i++){ - chr = *curr_pos; - val1 = g_ascii_xdigit_value(chr); + gchar chr1, chr2; + + chr1 = *curr_pos; + val1 = g_ascii_xdigit_value(chr1); curr_pos++; - chr = *curr_pos; - val2 = g_ascii_xdigit_value(chr); + chr2 = *curr_pos; + val2 = g_ascii_xdigit_value(chr2); if ((val1 != -1) && (val2 != -1)){ packet_buf[i] = ((guint8)val1 * 16) + val2; } else{ /* Something wrong, bail out */ - *err_info = g_strdup("Could not parse hex data"); + *err_info = g_strdup_printf("Could not parse hex data,bufzize %u index %u %c%c", + (pkt_data_len + exp_pdu_tags_len), + i, + chr1, + chr2); *err = WTAP_ERR_BAD_FILE; g_free(packet_buf); return WTAP_OPEN_ERROR;