From 48a66835ee4f319ba7806a542bb2cf1f16a2ac06 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Wed, 28 Sep 2016 16:45:23 -0700 Subject: Use wtap_read_bytes() to skip over bytes when reading a record. Allow file_read() to take a null pointer as a buffer argument; a null argument means "do everything except copy the bytes from the file to the user buffer". That means that wtap_read_bytes() and wtap_read_bytes_or_eof() also support a null pointer as a buffer argument. Use wtap_read_bytes() with a null buffer argument rather than file_skip() to skip forward over data. This fixes some places where files were mis-identified as ERF files, as the ERF open heuristics now get a short "read" error if they try to skip over more bytes than exist in the file. Change-Id: I4f73499d877c1f582e2bcf9b045034880cb09622 Reviewed-on: https://code.wireshark.org/review/17974 Reviewed-by: Guy Harris --- wiretap/peekclassic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'wiretap/peekclassic.c') diff --git a/wiretap/peekclassic.c b/wiretap/peekclassic.c index 5cbefbb394..91569e2abb 100644 --- a/wiretap/peekclassic.c +++ b/wiretap/peekclassic.c @@ -365,14 +365,15 @@ static gboolean peekclassic_read_v7(wtap *wth, int *err, gchar **err_info, /* Skip extra ignored data at the end of the packet. */ if ((guint32)sliceLength > wth->phdr.caplen) { - if (!file_skip(wth->fh, sliceLength - wth->phdr.caplen, err)) + if (!wtap_read_bytes(wth->fh, NULL, sliceLength - wth->phdr.caplen, + err, err_info)) return FALSE; } /* Records are padded to an even length, so if the slice length is odd, read the padding byte. */ if (sliceLength & 0x01) { - if (!file_skip(wth->fh, 1, err)) + if (!wtap_read_bytes(wth->fh, NULL, 1, err, err_info)) return FALSE; } -- cgit v1.2.1