When reading sequentially, pass the packet data length to
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 31 Dec 2013 23:43:54 +0000 (23:43 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 31 Dec 2013 23:43:54 +0000 (23:43 +0000)
ngsniffer_read_rec_data(), and separatelyskip extra data after that.

When reading randomly, use the packet length read from the packet
header.

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

wiretap/ngsniffer.c

index 9c1862350413d80bbdb22cd6110ea9b698a36fb1..cc86c1074f1c4c0bc1ec894f151ea734b20fa47d 100644 (file)
@@ -1224,10 +1224,18 @@ found:
        /*
         * Read the packet data.
         */
-       if (!ngsniffer_read_rec_data(wth, FALSE, wth->frame_buffer, length,
+       if (!ngsniffer_read_rec_data(wth, FALSE, wth->frame_buffer, size,
            err, err_info))
                return FALSE;   /* Read error */
 
+       /*
+        * Skip any extra data in the record.
+        */
+       if (size < length) {
+               if (!ng_file_skip_seq(wth, length - size, err, err_info))
+                       return FALSE;
+       }
+
        wth->phdr.pkt_encap = fix_pseudo_header(wth->file_encap, wth->frame_buffer, length,
            &wth->phdr.pseudo_header);
 
@@ -1266,7 +1274,7 @@ found:
 
 static gboolean
 ngsniffer_seek_read(wtap *wth, gint64 seek_off,
-    struct wtap_pkthdr *phdr, Buffer *buf, int packet_size,
+    struct wtap_pkthdr *phdr, Buffer *buf, int packet_size _U_,
     int *err, gchar **err_info)
 {
        union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
@@ -1339,10 +1347,10 @@ ngsniffer_seek_read(wtap *wth, gint64 seek_off,
        /*
         * Got the pseudo-header (if any), now get the data.
         */
-       if (!ngsniffer_read_rec_data(wth, TRUE, buf, packet_size, err, err_info))
+       if (!ngsniffer_read_rec_data(wth, TRUE, buf, phdr->caplen, err, err_info))
                return FALSE;
 
-       fix_pseudo_header(wth->file_encap, buf, packet_size, pseudo_header);
+       fix_pseudo_header(wth->file_encap, buf, phdr->caplen, pseudo_header);
 
        return TRUE;
 }