summaryrefslogtreecommitdiff
path: root/wiretap/peekclassic.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-06-03 00:26:16 +0000
committerGuy Harris <guy@alum.mit.edu>2013-06-03 00:26:16 +0000
commitc20b5d96a8899b1a72f5e57f4ffcd8f6c463041b (patch)
treea2d824b6af65e0af2f32703b0b2ec5ee15114e71 /wiretap/peekclassic.c
parentc3c6f93f5c749808350e4cafa58c62524701b38a (diff)
downloadwireshark-c20b5d96a8899b1a72f5e57f4ffcd8f6c463041b.tar.gz
When reading sequentially, skip past any ignored data at the end of the
packet. svn path=/trunk/; revision=49704
Diffstat (limited to 'wiretap/peekclassic.c')
-rw-r--r--wiretap/peekclassic.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/wiretap/peekclassic.c b/wiretap/peekclassic.c
index d547596ccc..e82b58446c 100644
--- a/wiretap/peekclassic.c
+++ b/wiretap/peekclassic.c
@@ -146,7 +146,7 @@ static gboolean peekclassic_seek_read_v7(wtap *wth, gint64 seek_off,
struct wtap_pkthdr *phdr, guint8 *pd, int length,
int *err, gchar **err_info);
static gboolean peekclassic_process_record_header_v7(wtap *wth, FILE_T fh,
- struct wtap_pkthdr *phdr, int *err, gchar **err_info);
+ struct wtap_pkthdr *phdr, guint *sliceLengthp, int *err, gchar **err_info);
static gboolean peekclassic_read_v56(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean peekclassic_seek_read_v56(wtap *wth, gint64 seek_off,
@@ -365,11 +365,13 @@ int peekclassic_open(wtap *wth, int *err, gchar **err_info)
static gboolean peekclassic_read_v7(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
+ guint sliceLength;
+
*data_offset = file_tell(wth->fh);
/* process the packet header */
if (!peekclassic_process_record_header_v7(wth, wth->fh, &wth->phdr,
- err, err_info))
+ &sliceLength, err, err_info))
return FALSE;
/* read the frame data */
@@ -377,9 +379,15 @@ static gboolean peekclassic_read_v7(wtap *wth, int *err, gchar **err_info,
wtap_file_read_expected_bytes(buffer_start_ptr(wth->frame_buffer),
wth->phdr.caplen, wth->fh, err, err_info);
+ /* Skip extra ignored data at the end of the packet. */
+ if (sliceLength > wth->phdr.caplen) {
+ if (!file_skip(wth->fh, sliceLength - wth->phdr.caplen, err))
+ return FALSE;
+ }
+
/* Records are padded to an even length, so if the slice length
is odd, read the padding byte. */
- if (wth->phdr.caplen & 0x01) {
+ if (sliceLength & 0x01) {
if (!file_skip(wth->fh, 1, err))
return FALSE;
}
@@ -396,7 +404,7 @@ static gboolean peekclassic_seek_read_v7(wtap *wth, gint64 seek_off,
/* process the packet header */
if (!peekclassic_process_record_header_v7(wth, wth->random_fh, phdr,
- err, err_info))
+ NULL, err, err_info))
return FALSE;
/*
@@ -409,7 +417,7 @@ static gboolean peekclassic_seek_read_v7(wtap *wth, gint64 seek_off,
}
static gboolean peekclassic_process_record_header_v7(wtap *wth, FILE_T fh,
- struct wtap_pkthdr *phdr, int *err, gchar **err_info)
+ struct wtap_pkthdr *phdr, guint *sliceLengthp, int *err, gchar **err_info)
{
guint8 ep_pkt[PEEKCLASSIC_V7_PKT_SIZE];
#if 0
@@ -485,6 +493,8 @@ static gboolean peekclassic_process_record_header_v7(wtap *wth, FILE_T fh,
break;
}
+ if (sliceLengthp)
+ *sliceLengthp = sliceLength;
return TRUE;
}