diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-09-28 16:45:23 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-09-28 23:45:58 +0000 |
commit | 48a66835ee4f319ba7806a542bb2cf1f16a2ac06 (patch) | |
tree | f4b86d49b651fc55047f16d98b1c2401238e03ec /wiretap/capsa.c | |
parent | a3ce2336b2a0e684a94d1e0046556bc0b42748f2 (diff) | |
download | wireshark-48a66835ee4f319ba7806a542bb2cf1f16a2ac06.tar.gz wireshark-48a66835ee4f319ba7806a542bb2cf1f16a2ac06.tar.bz2 wireshark-48a66835ee4f319ba7806a542bb2cf1f16a2ac06.zip |
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 <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/capsa.c')
-rw-r--r-- | wiretap/capsa.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/wiretap/capsa.c b/wiretap/capsa.c index 6f6ea15d30..1d65c1c33b 100644 --- a/wiretap/capsa.c +++ b/wiretap/capsa.c @@ -173,7 +173,7 @@ wtap_open_return_val capsa_open(wtap *wth, int *err, gchar **err_info) /* * Link speed, in megabytes/second? */ - if (!file_skip(wth->fh, 2, err)) + if (!wtap_read_bytes(wth->fh, NULL, 2, err, err_info)) return WTAP_OPEN_ERROR; /* @@ -181,19 +181,19 @@ wtap_open_return_val capsa_open(wtap *wth, int *err, gchar **err_info) * and two of which are zero? Two 2-byte numbers or flag fields, * both of which are 1? */ - if (!file_skip(wth->fh, 4, err)) + if (!wtap_read_bytes(wth->fh, NULL, 4, err, err_info)) return WTAP_OPEN_ERROR; /* * File size, in bytes. */ - if (!file_skip(wth->fh, 4, err)) + if (!wtap_read_bytes(wth->fh, NULL, 4, err, err_info)) return WTAP_OPEN_ERROR; /* * Zeroes? Or upper 4 bytes of file size? */ - if (!file_skip(wth->fh, 4, err)) + if (!wtap_read_bytes(wth->fh, NULL, 4, err, err_info)) return WTAP_OPEN_ERROR; /* @@ -251,7 +251,7 @@ static gboolean capsa_read(wtap *wth, int *err, gchar **err_info, * first byte. */ capsa->base_offset = file_tell(wth->fh); - if (!file_skip(wth->fh, 1, err)) + if (!wtap_read_bytes(wth->fh, NULL, 1, err, err_info)) return FALSE; /* @@ -265,7 +265,7 @@ static gboolean capsa_read(wtap *wth, int *err, gchar **err_info, * And finish processing all 805 bytes by skipping * the last 4 bytes. */ - if (!file_skip(wth->fh, 4, err)) + if (!wtap_read_bytes(wth->fh, NULL, 4, err, err_info)) return FALSE; } @@ -283,7 +283,7 @@ static gboolean capsa_read(wtap *wth, int *err, gchar **err_info, * Skip over the padding, if any. */ if (padbytes != 0) { - if (!file_skip(wth->fh, padbytes, err)) + if (!wtap_read_bytes(wth->fh, NULL, padbytes, err, err_info)) return FALSE; } @@ -339,8 +339,9 @@ capsa_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, * XXX - what is that? Measured statistics? * Calculated statistics? */ - if (!file_skip(fh, (capsarec_hdr.count1 + capsarec_hdr.count2)*4, - err)) + if (!wtap_read_bytes(fh, NULL, + (capsarec_hdr.count1 + capsarec_hdr.count2)*4, + err, err_info)) return -1; header_size += (capsarec_hdr.count1 + capsarec_hdr.count2)*4; break; |