diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-09-28 21:35:12 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-09-29 04:35:48 +0000 |
commit | e91af83c637adaa7a9837de65f50596a32b08db0 (patch) | |
tree | 0c18941d92ae6ec9274f9035dfc26ed369e11572 /wiretap/network_instruments.c | |
parent | 48b641576c53e9c7cef2e9487669460a975a0c0d (diff) |
Replace some seeks forward with wtap_read_bytes() with a null buffer pointer.
If the seek forward is just skipping record content that's not
(currently) interesting, use wtap_read_bytes() with a null buffer
pointer; it catches short "reads" and requires less seeking, so it may
work better when reading from a pipe.
Change-Id: Ifb07d20e0391a8ed97da85149d971b4e9ef093a8
Reviewed-on: https://code.wireshark.org/review/17976
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/network_instruments.c')
-rw-r--r-- | wiretap/network_instruments.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c index 286243a312..19ff6fbba8 100644 --- a/wiretap/network_instruments.c +++ b/wiretap/network_instruments.c @@ -170,6 +170,7 @@ wtap_open_return_val network_instruments_open(wtap *wth, int *err, gchar **err_i /* process (or skip over) the current TLV */ switch (tlvh.type) { case INFORMATION_TYPE_TIME_INFO: + /* XXX - what if tlvh.length != sizeof sizeof private_state->time_format? */ if (!wtap_read_bytes(wth->fh, &private_state->time_format, sizeof private_state->time_format, err, err_info)) @@ -180,7 +181,7 @@ wtap_open_return_val network_instruments_open(wtap *wth, int *err, gchar **err_i default: seek_increment = tlvh.length - (int)sizeof tlvh; if (seek_increment > 0) { - if (file_seek(wth->fh, seek_increment, SEEK_CUR, err) == -1) + if (!wtap_read_bytes(wth->fh, NULL, seek_increment, err, err_info)) return WTAP_OPEN_ERROR; } offset += seek_increment; @@ -196,7 +197,7 @@ wtap_open_return_val network_instruments_open(wtap *wth, int *err, gchar **err_i } seek_increment = header_offset - offset; if (seek_increment > 0) { - if (file_seek(wth->fh, seek_increment, SEEK_CUR, err) == -1) + if (!wtap_read_bytes(wth->fh, NULL, seek_increment, err, err_info)) return WTAP_OPEN_ERROR; } @@ -401,6 +402,7 @@ read_packet_header(wtap *wth, FILE_T fh, union wtap_pseudo_header *pseudo_header /* process (or skip over) the current TLV */ switch (tlvh.type) { case INFORMATION_TYPE_WIRELESS: + /* XXX - what if tlvh.length != sizeof wireless_header? */ if (!wtap_read_bytes(fh, &wireless_header, sizeof wireless_header, err, err_info)) return -1; @@ -419,7 +421,7 @@ read_packet_header(wtap *wth, FILE_T fh, union wtap_pseudo_header *pseudo_header /* skip the TLV data */ seek_increment = tlvh.length - (int)sizeof tlvh; if (seek_increment > 0) { - if (file_seek(fh, seek_increment, SEEK_CUR, err) == -1) + if (!wtap_read_bytes(fh, NULL, seek_increment, err, err_info)) return -1; } offset += seek_increment; @@ -524,7 +526,7 @@ read_packet_data(FILE_T fh, int offset_to_frame, int current_offset_from_packet_ /* skip to the packet data */ seek_increment = offset_to_frame - current_offset_from_packet_header; if (seek_increment > 0) { - if (file_seek(fh, seek_increment, SEEK_CUR, err) == -1) { + if (!wtap_read_bytes(fh, NULL, seek_increment, err, err_info)) { return -1; } bytes_consumed += seek_increment; @@ -558,7 +560,7 @@ skip_to_next_packet(wtap *wth, int offset_to_next_packet, int current_offset_fro /* skip to the next packet header */ seek_increment = offset_to_next_packet - current_offset_from_packet_header; if (seek_increment > 0) { - if (file_seek(wth->fh, seek_increment, SEEK_CUR, err) == -1) + if (!wtap_read_bytes(wth->fh, NULL, seek_increment, err, err_info)) return FALSE; } |