reordercap: Fix packet reordering with multiple IDB's not at the beginning of a pcapng file
Summary
When pcapng file has multiple interface description blocks (IDB's) not at the beginning of the file before the enhanced packet blocks (EPB's) then reordercap.exe will give an internal error.
Steps to reproduce
On the command line perform :
Good case : reordercap.exe multiple_idb_in_front.pcapng multiple_idb_in_front_ordered.pcapng 30 frames, 3 out of order
Bas case : reordercap.exe multiple_idb_scattered.pcapng multiple_idb_scattered_ordered.pcapng 30 frames, 3 out of order reordercap: An internal error occurred while writing record 5 of file "multiple_idb_scattered.pcapng" to the file "multiple_idb_scattered_ordered.pcapng". (pcapng: epb.interface_id (1) >= wdh->interface_data->len (1))
What is the current bug behavior?
Not correctly ordening the packets in the pcapng file. Problem seems to be known as comment in wiretap\pcapng.c mentions : /* XXX - This code expects that the PCAPNG Sections start with IDBs but the PCAPNG RFC does not say that!? */
What is the expected correct behavior?
Ordening correctly the packets independently of placement IDB's in pcapng
Sample capture file
multiple_idb_in_front_ordered.pcapng
multiple_idb_scattered_failing_ordered.pcapng
Relevant logs and/or screenshots
(pcapng: epb.interface_id (1) >= wdh->interface_data->len (1))
Build information
Version 4.0.10 (v4.0.10-0-gf5c7c25a81eb).
Compiled (64-bit) using Microsoft Visual Studio 2022 (VC++ 14.37, build 32822), with GLib 2.72.3, with PCRE2, with zlib 1.2.12, with Qt 5.15.2, with libpcap, with Lua 5.2.4, with GnuTLS 3.6.3 and PKCS #11 (closed) support, with Gcrypt 1.10.1, with Kerberos (MIT), with MaxMind, with nghttp2 1.46.0, with brotli, with LZ4, with Zstandard, with Snappy, with libxml2 2.9.14, with libsmi 0.4.8, with QtMultimedia, with automatic updates using WinSparkle 0.8.0, with AirPcap, with SpeexDSP (using bundled resampler), with Minizip, with binary plugins.
Running on 64-bit Windows 10 (22H2), build 19045, with Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz (with SSE4.2), with 32545 MB of physical memory, with GLib 2.72.3, with PCRE2 10.40 2022-04-14, with Qt 5.15.2, with Npcap version 1.71, based on libpcap version 1.10.2-PRE-GIT, with c-ares 1.18.1, with GnuTLS 3.6.3, with Gcrypt 1.10.1, with nghttp2 1.46.0, with brotli 1.0.9, with LZ4 1.9.3, with Zstandard 1.5.2, without AirPcap, with light display mode, without HiDPI, with LC_TYPE=Dutch_Belgium.utf8, binary plugins supported.