diff options
author | Anders Broman <anders.broman@ericsson.com> | 2018-11-14 14:24:22 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-11-14 13:58:47 +0000 |
commit | db7653fd2ce8542a8648dad0c8360c3eb82e6ec0 (patch) | |
tree | 4a3caa3b6f2aafee0aebc38201111a68b686f523 | |
parent | e26f464fbd70452996f20fe5e378f5cf8b5d0dd7 (diff) |
nettrace_3gpp_32_423: Don't crash on error and improve error output.
Change-Id: I4ea7ccf51321d6ce316456bde24aa37880ea52ed
Reviewed-on: https://code.wireshark.org/review/30627
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r-- | wiretap/nettrace_3gpp_32_423.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/wiretap/nettrace_3gpp_32_423.c b/wiretap/nettrace_3gpp_32_423.c index 793d29d975..a7a9a94a76 100644 --- a/wiretap/nettrace_3gpp_32_423.c +++ b/wiretap/nettrace_3gpp_32_423.c @@ -852,10 +852,22 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_ curr_pos = packet_buf + 12; /* Find the file header */ curr_pos = strstr(curr_pos, "<fileHeader"); + if (!curr_pos) { + *err = WTAP_ERR_BAD_FILE; + *err_info = g_strdup("Could not parse \"<fileHeader\""); + result = WTAP_OPEN_ERROR; + goto end; + } curr_pos = curr_pos + 11; /* Find start time */ curr_pos = strstr(curr_pos, "<traceCollec beginTime=\""); + if (!curr_pos) { + *err = WTAP_ERR_BAD_FILE; + *err_info = g_strdup("Could not parse \"<traceCollec beginTime=\""); + result = WTAP_OPEN_ERROR; + goto end; + } curr_pos = curr_pos + 24; curr_pos = nettrace_parse_begin_time(curr_pos, &rec); @@ -893,7 +905,10 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_ next_msg_pos = strstr(curr_pos, "</msg>"); if (!next_msg_pos){ /* Somethings wrong, bail out */ - break; + *err = WTAP_ERR_BAD_FILE; + *err_info = g_strdup("Did not find \"</msg>\""); + result = WTAP_OPEN_ERROR; + goto end; } next_msg_pos = next_msg_pos + 6; /* Check if we have a time stamp "changeTime" @@ -909,6 +924,8 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_ next_pos = strstr(curr_pos, "\""); name_str_len = (int)(next_pos - curr_pos); if (name_str_len > 63) { + *err = WTAP_ERR_BAD_FILE; + *err_info = g_strdup("name_str_len > 63"); return WTAP_OPEN_ERROR; } |