Handle the case where there are no IDBs before the first non-SHB/non-IDB
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 22 Feb 2012 03:03:34 +0000 (03:03 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 22 Feb 2012 03:03:34 +0000 (03:03 +0000)
block, which could be the case even in a *valid* file (consider a file
with an SHB, an NRB, an IDB, and a packet block, in that order); even if
there's no IDB before the first packet block, that should be reported to
the user as "interface N not less than interface count M", to more
precisely indicate the problem.

(Yes, the loop should probably keep going until it finds a packet block,
not just a non-IDB block.)

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@41132 f5534014-38df-0310-8fa8-9805f1628bb7

wiretap/pcapng.c

index c46142a..c79a089 100644 (file)
@@ -1632,6 +1632,10 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
        while(1){
                bytes_read = pcapng_read_block(wth->fh, FALSE, &pn, &wblock, err, err_info);
                wth->data_offset += bytes_read;
+               if (bytes_read == 0) {
+                       pcapng_debug0("No more IDBs available...");
+                       break;
+               }
                if (bytes_read <= 0) {
                        pcapng_debug0("pcapng_open: couldn't read IDB");
                        *err = file_error(wth->fh, err_info);