diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-08-23 16:13:20 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-08-23 23:15:00 +0000 |
commit | 5ed7a401bb224d9cacb692115045b24c8febff32 (patch) | |
tree | 6dbb15269ec5e98974fe046446df99a621e79532 /capinfos.c | |
parent | ce38df527f50ee0d85c80b9ace5989c4496648ec (diff) |
Don't assume we have interface information.
Not all capture file formats provide interface information. Check
whether we have it, and don't fail if we don't have any.
(Note that the current version of the pcapng specification in the Git
repository does not require that there be at least one IDB in a file,
only that there must be an IDB for each interface to which other blocks
in a file refers.)
Change-Id: Ia796f639ed3a8cb21e1dbe9b2bc6b4b66c7be479
Reviewed-on: https://code.wireshark.org/review/10220
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'capinfos.c')
-rw-r--r-- | capinfos.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/capinfos.c b/capinfos.c index 457919a448..73bdf35f22 100644 --- a/capinfos.c +++ b/capinfos.c @@ -685,7 +685,7 @@ print_stats(const gchar *filename, capture_info *cf_info) printf ("Capture application: %s\n", cf_info->usr_appl); } - if (cap_file_idb) { + if (cap_file_idb && cf_info->num_interfaces != 0) { guint i; g_assert(cf_info->num_interfaces == cf_info->idb_info_strings->len); printf ("Number of interfaces in file: %u\n", cf_info->num_interfaces); @@ -1065,9 +1065,7 @@ process_cap_file(wtap *wth, const char *filename) idb_info = wtap_file_get_idb_info(wth); - /* every file should have at least one IDB, or else it's an internal programming error */ g_assert(idb_info->interface_data != NULL); - g_assert(idb_info->interface_data->len > 0); cf_info.num_interfaces = idb_info->interface_data->len; cf_info.interface_ids = g_new0(guint32, cf_info.num_interfaces); @@ -1152,7 +1150,12 @@ process_cap_file(wtap *wth, const char *filename) } else { /* it's for interface_id 0 */ - cf_info.interface_ids[0] += 1; + if (cf_info.num_interfaces != 0) { + cf_info.interface_ids[0] += 1; + } + else { + cf_info.pkt_interface_id_unknown += 1; + } } } |