diff options
author | Martin Kaiser <wireshark@kaiser.cx> | 2016-01-17 17:03:50 +0100 |
---|---|---|
committer | Alexis La Goutte <alexis.lagoutte@gmail.com> | 2016-01-17 19:05:30 +0000 |
commit | 96d585a5e9baef21e1eea8505d78305b034dc80e (patch) | |
tree | 6ce7bdc1cb270b162caf7947ce04f09cec8d186a /wiretap | |
parent | 8a0966c434231e515bc8c5e2130b8a7d8121b37f (diff) |
[iseries] fix iseries_check_file_type()
check that we have a line that contains OBJECT PROTOCOL ETHERNET
(at the moment, we fail if there's a line containing OBJECT PROTOCOL but
not ETHERNET and succeed otherwise
-> a file with some random lines will be identified as iseries)
initialize our line buffer with 0s to make sure we don't access uninitialized
data while parsing
don't set wth->priv unless the file is really an iseries file
free the iseries struct if the file is not our type
Bug: 11985
Change-Id: I0ac7003c047f54ca025d02e59b56d1ff4e2a6be7
Reviewed-on: https://code.wireshark.org/review/13360
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/iseries.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/wiretap/iseries.c b/wiretap/iseries.c index 2f5bc656f7..1f04e8572a 100644 --- a/wiretap/iseries.c +++ b/wiretap/iseries.c @@ -304,6 +304,7 @@ iseries_open (wtap * wth, int *err, gchar ** err_info) static gboolean iseries_check_file_type (wtap * wth, int *err, gchar **err_info, int format) { + gboolean is_iseries = FALSE; guint line; int num_items_scanned; char buf[ISERIES_LINE_LENGTH], protocol[9]; @@ -311,19 +312,19 @@ iseries_check_file_type (wtap * wth, int *err, gchar **err_info, int format) /* Save trace format for passing between packets */ iseries = (iseries_t *) g_malloc (sizeof (iseries_t)); - wth->priv = (void *) iseries; iseries->have_date = FALSE; iseries->format = format; for (line = 0; line < ISERIES_HDR_LINES_TO_CHECK; line++) { + memset(buf, 0x0, sizeof(buf)); if (file_gets (buf, ISERIES_LINE_LENGTH, wth->fh) == NULL) { /* EOF or error. */ *err = file_error (wth->fh, err_info); if (*err == WTAP_ERR_SHORT_READ) *err = 0; - return FALSE; + break; } /* @@ -339,8 +340,11 @@ iseries_check_file_type (wtap * wth, int *err, gchar **err_info, int format) protocol); if (num_items_scanned == 1) { - if (memcmp (protocol, "ETHERNET", 8) != 0) - return FALSE; + if (memcmp (protocol, "ETHERNET", 8) == 0) + { + *err = 0; + is_iseries = TRUE; + } } /* @@ -356,8 +360,13 @@ iseries_check_file_type (wtap * wth, int *err, gchar **err_info, int format) iseries->have_date = TRUE; } } - *err = 0; - return TRUE; + + if (is_iseries) + wth->priv = (void *) iseries; + else + g_free(iseries); + + return is_iseries; } /* |