Skip to content

Commit

Permalink
Don't assume we have interface information.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
guyharris committed Aug 23, 2015
1 parent ce38df5 commit 5ed7a40
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions capinfos.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit 5ed7a40

Please sign in to comment.