diff options
author | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2002-06-07 07:27:35 +0000 |
---|---|---|
committer | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2002-06-07 07:27:35 +0000 |
commit | cfc912ef0ce1948bd6738533390303874d9fd44b (patch) | |
tree | fc165ec22e943d3b15a10b6c8c84359286432e05 /wiretap | |
parent | 8508f775b09925ad4cc117c972dc821a3568afe0 (diff) |
Graeme Hewson noted that zlib has a bug wherein "gzseek()" doesn't set
the internal z_err value for the stream if an "fseek()" call it makes
fails, so that if "gzerror()" is subsequently called, it returns Z_OK
rather than an error.
To work around this, we pass "file_seek()" an "int *err", and have the
with-zlib version of "file_seek()" check, if "gzseek()" fails, whether
the return value of "file_error()" is 0 and, if so, have it return
"errno" instead.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@5642 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/ascend.c | 14 | ||||
-rw-r--r-- | wiretap/csids.c | 10 | ||||
-rw-r--r-- | wiretap/dbs-etherwatch.c | 6 | ||||
-rw-r--r-- | wiretap/etherpeek.c | 6 | ||||
-rw-r--r-- | wiretap/file.c | 9 | ||||
-rw-r--r-- | wiretap/file_wrappers.c | 34 | ||||
-rw-r--r-- | wiretap/file_wrappers.h | 6 | ||||
-rw-r--r-- | wiretap/i4btrace.c | 10 | ||||
-rw-r--r-- | wiretap/iptrace.c | 10 | ||||
-rw-r--r-- | wiretap/lanalyzer.c | 8 | ||||
-rw-r--r-- | wiretap/libpcap.c | 28 | ||||
-rw-r--r-- | wiretap/netmon.c | 13 | ||||
-rw-r--r-- | wiretap/nettl.c | 14 | ||||
-rw-r--r-- | wiretap/netxray.c | 13 | ||||
-rw-r--r-- | wiretap/ngsniffer.c | 40 | ||||
-rw-r--r-- | wiretap/pppdump.c | 10 | ||||
-rw-r--r-- | wiretap/radcom.c | 34 | ||||
-rw-r--r-- | wiretap/snoop.c | 6 | ||||
-rw-r--r-- | wiretap/toshiba.c | 6 | ||||
-rw-r--r-- | wiretap/visual.c | 6 | ||||
-rw-r--r-- | wiretap/vms.c | 9 |
21 files changed, 109 insertions, 183 deletions
diff --git a/wiretap/ascend.c b/wiretap/ascend.c index 6710cadece..f3f97388f1 100644 --- a/wiretap/ascend.c +++ b/wiretap/ascend.c @@ -1,6 +1,6 @@ /* ascend.c * - * $Id: ascend.c,v 1.29 2002/03/05 08:39:29 guy Exp $ + * $Id: ascend.c,v 1.30 2002/06/07 07:27:34 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -227,10 +227,8 @@ found: * Move to where the read for this packet should start, and return * that seek offset. */ - if (file_seek(wth->fh, packet_off, SEEK_SET) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, packet_off, SEEK_SET, err) == -1) return -1; - } return packet_off; } @@ -296,10 +294,8 @@ static gboolean ascend_read(wtap *wth, int *err, long *data_offset) offset after the header of the previous packet and try to find the next packet. */ if (file_seek(wth->fh, wth->capture.ascend->next_packet_seek_start, - SEEK_SET) == -1) { - *err = file_error(wth->fh); + SEEK_SET, err) == -1) return FALSE; - } offset = ascend_seek(wth, ASCEND_MAX_SEEK, err); if (offset == -1) return FALSE; @@ -343,10 +339,8 @@ static gboolean ascend_read(wtap *wth, int *err, long *data_offset) static gboolean ascend_seek_read (wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err) { - if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - } if (! parse_ascend(wth->random_fh, pd, &pseudo_header->ascend, NULL, len)) { *err = WTAP_ERR_BAD_RECORD; return FALSE; diff --git a/wiretap/csids.c b/wiretap/csids.c index fd830246d8..ce819a71d3 100644 --- a/wiretap/csids.c +++ b/wiretap/csids.c @@ -1,6 +1,6 @@ /* csids.c * - * $Id: csids.c,v 1.13 2002/03/05 08:39:29 guy Exp $ + * $Id: csids.c,v 1.14 2002/06/07 07:27:34 guy Exp $ * * Copyright (c) 2000 by Mike Hall <mlh@io.com> * Copyright (c) 2000 by Cisco Systems @@ -124,10 +124,8 @@ int csids_open(wtap *wth, int *err) } /* no file header. So reset the fh to 0 so we can read the first packet */ - if (file_seek(wth->fh, 0, SEEK_SET) == -1) { - *err = file_error( wth->fh ); + if (file_seek(wth->fh, 0, SEEK_SET, err) == -1) return -1; - } wth->data_offset = 0; wth->capture.csids = g_malloc(sizeof(csids_t)); @@ -208,10 +206,8 @@ csids_seek_read (wtap *wth, int bytesRead; struct csids_header hdr; - if( file_seek( wth->random_fh, seek_off, SEEK_SET ) == -1 ) { - *err = file_error( wth->random_fh ); + if( file_seek( wth->random_fh, seek_off, SEEK_SET, err ) == -1 ) return FALSE; - } bytesRead = file_read( &hdr, 1, sizeof( struct csids_header), wth->random_fh ); if( bytesRead != sizeof( struct csids_header) ) { diff --git a/wiretap/dbs-etherwatch.c b/wiretap/dbs-etherwatch.c index fbe3d582fd..66a81232e6 100644 --- a/wiretap/dbs-etherwatch.c +++ b/wiretap/dbs-etherwatch.c @@ -1,6 +1,6 @@ /* dbs-etherwatch.c * - * $Id: dbs-etherwatch.c,v 1.7 2002/03/05 08:39:29 guy Exp $ + * $Id: dbs-etherwatch.c,v 1.8 2002/06/07 07:27:34 guy Exp $ * * Wiretap Library * Copyright (c) 2001 by Marc Milgram <mmilgram@arrayinc.com> @@ -230,10 +230,8 @@ dbs_etherwatch_seek_read (wtap *wth, long seek_off, { int pkt_len; - if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1) return FALSE; - } pkt_len = parse_dbs_etherwatch_rec_hdr(NULL, wth->random_fh, err); diff --git a/wiretap/etherpeek.c b/wiretap/etherpeek.c index ee55db7405..5818ffce94 100644 --- a/wiretap/etherpeek.c +++ b/wiretap/etherpeek.c @@ -2,7 +2,7 @@ * Routines for opening EtherPeek (and TokenPeek?) files * Copyright (c) 2001, Daniel Thompson <d.thompson@gmx.net> * - * $Id: etherpeek.c,v 1.19 2002/04/08 10:01:26 guy Exp $ + * $Id: etherpeek.c,v 1.20 2002/06/07 07:27:34 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -446,10 +446,8 @@ etherpeek_seek_read_v7(wtap *wth, long seek_off, { airopeek_radio_hdr_t radio_hdr; - if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - } if (wth->file_encap == WTAP_ENCAP_IEEE_802_11_WITH_RADIO) { /* diff --git a/wiretap/file.c b/wiretap/file.c index 178a109237..973cc94821 100644 --- a/wiretap/file.c +++ b/wiretap/file.c @@ -1,6 +1,6 @@ /* file.c * - * $Id: file.c,v 1.90 2002/05/29 02:19:49 guy Exp $ + * $Id: file.c,v 1.91 2002/06/07 07:27:34 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -129,10 +129,8 @@ gboolean wtap_def_seek_read(wtap *wth, long seek_off, { int bytes_read; - if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - } bytes_read = file_read(pd, sizeof(guint8), len, wth->random_fh); if (bytes_read != len) { @@ -240,9 +238,8 @@ wtap* wtap_open_offline(const char *filename, int *err, gboolean do_random) to start reading at the beginning. Initialize the data offset while we're at it. */ - if (file_seek(wth->fh, 0, SEEK_SET) == -1) { + if (file_seek(wth->fh, 0, SEEK_SET, err) == -1) { /* I/O error - give up */ - *err = file_error(wth->fh); if (wth->random_fh != NULL) file_close(wth->random_fh); file_close(wth->fh); diff --git a/wiretap/file_wrappers.c b/wiretap/file_wrappers.c index c69a00daac..ae8a98706d 100644 --- a/wiretap/file_wrappers.c +++ b/wiretap/file_wrappers.c @@ -1,6 +1,6 @@ /* file_wrappers.c * - * $Id: file_wrappers.c,v 1.10 2002/02/06 09:58:30 guy Exp $ + * $Id: file_wrappers.c,v 1.11 2002/06/07 07:27:34 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -104,9 +104,26 @@ #ifdef HAVE_LIBZ long -file_seek(void *stream, long offset, int whence) +file_seek(void *stream, long offset, int whence, int *err) { - return gzseek(stream, (z_off_t)offset, whence); + long ret; + + ret = gzseek(stream, (z_off_t)offset, whence); + if (ret == -1) { + /* + * XXX - "gzseek()", as of zlib 1.1.4, doesn't set + * "z_err" for the stream, so "gzerror()" could return + * a bogus Z_OK. + * + * As this call failed, we know "gzerror()" shouldn't + * return Z_OK; if it does, we assume that "errno" is + * the real error. + */ + *err = file_error(stream); + if (*err == 0) + *err = errno; + } + return ret; } long @@ -114,6 +131,17 @@ file_tell(void *stream) { return (long)gztell(stream); } +#else /* HAVE_LIBZ */ +long +file_seek(void *stream, long offset, int whence, int *err) +{ + long ret; + + ret = fseek(stream, offset, whence); + if (ret == -1) + *err = file_error(stream); + return ret; +} #endif /* HAVE_LIBZ */ /* diff --git a/wiretap/file_wrappers.h b/wiretap/file_wrappers.h index efeb96e35a..ee29c7a3bf 100644 --- a/wiretap/file_wrappers.h +++ b/wiretap/file_wrappers.h @@ -1,6 +1,6 @@ /* file_wrappers.h * - * $Id: file_wrappers.h,v 1.8 2002/03/04 00:25:35 guy Exp $ + * $Id: file_wrappers.h,v 1.9 2002/06/07 07:27:34 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -28,7 +28,7 @@ #define file_open gzopen #define filed_open gzdopen -extern long file_seek(void *stream, long offset, int whence); +extern long file_seek(void *stream, long offset, int whence, int *err); #define file_read(buf, bsize, count, file) gzread((file),(buf),((count)*(bsize))) #define file_write(buf, bsize, count, file) gzwrite((file),(buf),((count)*(bsize))) #define file_close gzclose @@ -41,7 +41,7 @@ extern int file_error(void *fh); #else /* No zLib */ #define file_open fopen #define filed_open fdopen -#define file_seek fseek +extern long file_seek(void *stream, long offset, int whence, int *err); #define file_read fread #define file_write fwrite #define file_close fclose diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c index 9b9eec2066..1ed623fd16 100644 --- a/wiretap/i4btrace.c +++ b/wiretap/i4btrace.c @@ -1,6 +1,6 @@ /* i4btrace.c * - * $Id: i4btrace.c,v 1.20 2002/04/09 08:15:04 guy Exp $ + * $Id: i4btrace.c,v 1.21 2002/06/07 07:27:34 guy Exp $ * * Wiretap Library * Copyright (c) 1999 by Bert Driehuis <driehuis@playbeing.org> @@ -90,10 +90,8 @@ int i4btrace_open(wtap *wth, int *err) byte_swapped = TRUE; } - if (file_seek(wth->fh, 0, SEEK_SET) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, 0, SEEK_SET, err) == -1) return -1; - } wth->data_offset = 0; /* Get capture start time */ @@ -230,10 +228,8 @@ i4btrace_seek_read(wtap *wth, long seek_off, int ret; i4b_trace_hdr_t hdr; - if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - } /* Read record header. */ ret = i4b_read_rec_header(wth->random_fh, &hdr, err); diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c index bbd89ddba3..945d842cdf 100644 --- a/wiretap/iptrace.c +++ b/wiretap/iptrace.c @@ -1,6 +1,6 @@ /* iptrace.c * - * $Id: iptrace.c,v 1.40 2002/04/30 18:58:16 guy Exp $ + * $Id: iptrace.c,v 1.41 2002/06/07 07:27:34 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -172,10 +172,8 @@ static gboolean iptrace_seek_read_1_0(wtap *wth, long seek_off, int ret; guint8 header[30]; - if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - } /* Read the descriptor data */ ret = iptrace_read_rec_header(wth->random_fh, header, 30, err); @@ -295,10 +293,8 @@ static gboolean iptrace_seek_read_2_0(wtap *wth, long seek_off, int ret; guint8 header[40]; - if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - } /* Read the descriptor data */ ret = iptrace_read_rec_header(wth->random_fh, header, 40, err); diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c index 6372e99c03..45b5e5b8f0 100644 --- a/wiretap/lanalyzer.c +++ b/wiretap/lanalyzer.c @@ -1,6 +1,6 @@ /* lanalyzer.c * - * $Id: lanalyzer.c,v 1.32 2002/05/23 06:34:10 guy Exp $ + * $Id: lanalyzer.c,v 1.33 2002/06/07 07:27:35 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -90,8 +90,7 @@ int lanalyzer_open(wtap *wth, int *err) /* Read records until we find the start of packets */ while (1) { - if (file_seek(wth->fh, record_length, SEEK_CUR) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, record_length, SEEK_CUR, err) == -1) { g_free(wth->capture.lanalyzer); return -1; } @@ -184,8 +183,7 @@ int lanalyzer_open(wtap *wth, int *err) case REC_TRACE_PACKET_DATA: /* Go back header number ob ytes so that lanalyzer_read * can read this header */ - if (file_seek(wth->fh, -bytes_read, SEEK_CUR) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, -bytes_read, SEEK_CUR, err) == -1) { g_free(wth->capture.lanalyzer); return -1; } diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c index 7702c387b2..57fb13453c 100644 --- a/wiretap/libpcap.c +++ b/wiretap/libpcap.c @@ -1,6 +1,6 @@ /* libpcap.c * - * $Id: libpcap.c,v 1.74 2002/06/07 04:48:36 guy Exp $ + * $Id: libpcap.c,v 1.75 2002/06/07 07:27:35 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -604,8 +604,7 @@ int libpcap_open(wtap *wth, int *err) * Well, it looks as if it might be 991029. * Put the seek pointer back, and return success. */ - if (file_seek(wth->fh, wth->data_offset, SEEK_SET) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) { g_free(wth->capture.pcap); return -1; } @@ -626,8 +625,7 @@ int libpcap_open(wtap *wth, int *err) * it as 990915. */ wth->file_type = WTAP_FILE_PCAP_SS990915; - if (file_seek(wth->fh, wth->data_offset, SEEK_SET) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) { g_free(wth->capture.pcap); return -1; } @@ -654,8 +652,7 @@ int libpcap_open(wtap *wth, int *err) * libpcap file. * Put the seek pointer back, and return success. */ - if (file_seek(wth->fh, wth->data_offset, SEEK_SET) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) { g_free(wth->capture.pcap); return -1; } @@ -674,8 +671,7 @@ int libpcap_open(wtap *wth, int *err) * ss990417. */ wth->file_type = WTAP_FILE_PCAP_SS990417; - if (file_seek(wth->fh, wth->data_offset, SEEK_SET) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) { g_free(wth->capture.pcap); return -1; } @@ -694,8 +690,7 @@ int libpcap_open(wtap *wth, int *err) * Well, it looks as if it might be ss990417. * Put the seek pointer back, and return success. */ - if (file_seek(wth->fh, wth->data_offset, SEEK_SET) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) { g_free(wth->capture.pcap); return -1; } @@ -716,8 +711,7 @@ int libpcap_open(wtap *wth, int *err) * and treat it as a Nokia file. */ wth->file_type = WTAP_FILE_PCAP_NOKIA; - if (file_seek(wth->fh, wth->data_offset, SEEK_SET) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) { g_free(wth->capture.pcap); return -1; } @@ -770,10 +764,8 @@ static libpcap_try_t libpcap_try(wtap *wth, int *err) * Now skip over the first record's data, under the assumption * that the header is sane. */ - if (file_seek(wth->fh, first_rec_hdr.hdr.incl_len, SEEK_CUR) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, first_rec_hdr.hdr.incl_len, SEEK_CUR, err) == -1) return BAD_READ; - } /* * Now attempt to read the second record's header. @@ -885,10 +877,8 @@ static gboolean libpcap_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err) { - if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - } if (wth->file_encap == WTAP_ENCAP_ATM_SNIFFER) { if (!libpcap_read_atm_pseudoheader(wth->random_fh, pseudo_header, diff --git a/wiretap/netmon.c b/wiretap/netmon.c index 6268840d1e..3de968242c 100644 --- a/wiretap/netmon.c +++ b/wiretap/netmon.c @@ -1,6 +1,6 @@ /* netmon.c * - * $Id: netmon.c,v 1.55 2002/06/04 21:55:38 guy Exp $ + * $Id: netmon.c,v 1.56 2002/06/07 07:27:35 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -269,8 +269,7 @@ int netmon_open(wtap *wth, int *err) *err = WTAP_ERR_UNSUPPORTED; return -1; } - if (file_seek(wth->fh, frame_table_offset, SEEK_SET) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, frame_table_offset, SEEK_SET, err) == -1) { g_free(wth->capture.netmon); return -1; } @@ -334,10 +333,8 @@ static gboolean netmon_read(wtap *wth, int *err, long *data_offset) rec_offset = netmon->frame_table[netmon->current_frame]; if (wth->data_offset != rec_offset) { wth->data_offset = rec_offset; - if (file_seek(wth->fh, wth->data_offset, SEEK_SET) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) return FALSE; - } } netmon->current_frame++; @@ -452,10 +449,8 @@ static gboolean netmon_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err) { - if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - } if (wth->file_encap == WTAP_ENCAP_ATM_SNIFFER) { if (!netmon_read_atm_pseudoheader(wth->random_fh, pseudo_header, diff --git a/wiretap/nettl.c b/wiretap/nettl.c index 14bc109059..9780ffed30 100644 --- a/wiretap/nettl.c +++ b/wiretap/nettl.c @@ -1,6 +1,6 @@ /* nettl.c * - * $Id: nettl.c,v 1.28 2002/05/22 10:53:17 sahlberg Exp $ + * $Id: nettl.c,v 1.29 2002/06/07 07:27:35 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -154,10 +154,8 @@ int nettl_open(wtap *wth, int *err) return 0; } - if (file_seek(wth->fh, 0x63, SEEK_SET) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, 0x63, SEEK_SET, err) == -1) return -1; - } wth->data_offset = 0x63; bytes_read = file_read(os_vers, 1, 2, wth->fh); if (bytes_read != 2) { @@ -167,10 +165,8 @@ int nettl_open(wtap *wth, int *err) return 0; } - if (file_seek(wth->fh, 0x80, SEEK_SET) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, 0x80, SEEK_SET, err) == -1) return -1; - } wth->data_offset = 0x80; /* This is an nettl file */ @@ -222,10 +218,8 @@ nettl_seek_read(wtap *wth, long seek_off, int ret; struct wtap_pkthdr phdr; - if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - } /* Read record header. */ ret = nettl_read_rec_header(wth, wth->random_fh, &phdr, pseudo_header, diff --git a/wiretap/netxray.c b/wiretap/netxray.c index 545fb1cc97..1500e92dde 100644 --- a/wiretap/netxray.c +++ b/wiretap/netxray.c @@ -1,6 +1,6 @@ /* netxray.c * - * $Id: netxray.c,v 1.55 2002/05/28 02:39:15 guy Exp $ + * $Id: netxray.c,v 1.56 2002/06/07 07:27:35 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -291,8 +291,7 @@ int netxray_open(wtap *wth, int *err) wth->capture.netxray->end_offset = pletohl(&hdr.end_offset); /* Seek to the beginning of the data records. */ - if (file_seek(wth->fh, pletohl(&hdr.start_offset), SEEK_SET) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, pletohl(&hdr.start_offset), SEEK_SET, err) == -1) { g_free(wth->capture.netxray); return -1; } @@ -334,10 +333,8 @@ reread: /* Yes. Remember that we did. */ wth->capture.netxray->wrapped = TRUE; if (file_seek(wth->fh, CAPTUREFILE_HEADER_SIZE, - SEEK_SET) == -1) { - *err = file_error(wth->fh); + SEEK_SET, err) == -1) return FALSE; - } wth->data_offset = CAPTUREFILE_HEADER_SIZE; goto reread; } @@ -411,10 +408,8 @@ netxray_seek_read(wtap *wth, long seek_off, { union netxrayrec_hdr hdr; - if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - } if (!netxray_read_rec_header(wth, wth->random_fh, &hdr, err)) { if (*err == 0) { diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c index e3e50f5dac..219f8ec469 100644 --- a/wiretap/ngsniffer.c +++ b/wiretap/ngsniffer.c @@ -1,6 +1,6 @@ /* ngsniffer.c * - * $Id: ngsniffer.c,v 1.81 2002/06/04 21:56:45 guy Exp $ + * $Id: ngsniffer.c,v 1.82 2002/06/07 07:27:35 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -458,10 +458,8 @@ int ngsniffer_open(wtap *wth, int *err) * "ngsniffer_read()". */ if (wth->random_fh != NULL) { - if (file_seek(wth->random_fh, wth->data_offset, SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + if (file_seek(wth->random_fh, wth->data_offset, SEEK_SET, err) == -1) return -1; - } } /* This is a ngsniffer file */ @@ -564,10 +562,8 @@ skip_header_records(wtap *wth, int *err, gint16 version) * which implies data. Seek backwards over the * two bytes we read, and return. */ - if (file_seek(wth->fh, -2, SEEK_CUR) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, -2, SEEK_CUR, err) == -1) return -1; - } return 0; } @@ -612,10 +608,8 @@ skip_header_records(wtap *wth, int *err, gint16 version) */ if (length > sizeof buffer) { if (file_seek(wth->fh, length - sizeof buffer, - SEEK_CUR) == -1) { - *err = file_error(wth->fh); + SEEK_CUR, err) == -1) return -1; - } } /* @@ -648,10 +642,8 @@ skip_header_records(wtap *wth, int *err, gint16 version) } else { /* Nope, just skip over the data. */ - if (file_seek(wth->fh, length, SEEK_CUR) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, length, SEEK_CUR, err) == -1) return -1; - } } wth->data_offset += length; } @@ -1948,17 +1940,12 @@ read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream, int *err) static long ng_file_seek_seq(wtap *wth, long offset, int whence, int *err) { - long ret; long delta; char buf[65536]; long amount_to_read; - if (wth->file_type == WTAP_FILE_NGSNIFFER_UNCOMPRESSED) { - ret = file_seek(wth->fh, offset, whence); - if (ret == -1) - *err = file_error(wth->fh); - return ret; - } + if (wth->file_type == WTAP_FILE_NGSNIFFER_UNCOMPRESSED) + return file_seek(wth->fh, offset, whence, err); switch (whence) { @@ -2000,18 +1987,13 @@ ng_file_seek_seq(wtap *wth, long offset, int whence, int *err) static long ng_file_seek_rand(wtap *wth, long offset, int whence, int *err) { - long ret; ngsniffer_t *ngsniffer; long delta; GList *new, *next; blob_info_t *next_blob, *new_blob; - if (wth->file_type == WTAP_FILE_NGSNIFFER_UNCOMPRESSED) { - ret = file_seek(wth->random_fh, offset, whence); - if (ret == -1) - *err = file_error(wth->random_fh); - return ret; - } + if (wth->file_type == WTAP_FILE_NGSNIFFER_UNCOMPRESSED) + return file_seek(wth->random_fh, offset, whence, err); ngsniffer = wth->capture.ngsniffer; @@ -2086,10 +2068,8 @@ ng_file_seek_rand(wtap *wth, long offset, int whence, int *err) /* Seek in the compressed file to the offset in the compressed file of the beginning of that blob. */ - if (file_seek(wth->random_fh, new_blob->blob_comp_offset, SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + if (file_seek(wth->random_fh, new_blob->blob_comp_offset, SEEK_SET, err) == -1) return -1; - } /* Make the blob we found the current one. */ ngsniffer->current_blob = new; diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c index d11aeaf6bd..d267ea914a 100644 --- a/wiretap/pppdump.c +++ b/wiretap/pppdump.c @@ -1,6 +1,6 @@ /* pppdump.c * - * $Id: pppdump.c,v 1.18 2002/05/29 02:11:57 guy Exp $ + * $Id: pppdump.c,v 1.19 2002/06/07 07:27:35 guy Exp $ * * Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu> * @@ -195,10 +195,8 @@ pppdump_open(wtap *wth, int *err) my_file_type: - if (file_seek(wth->fh, 5, SEEK_SET) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, 5, SEEK_SET, err) == -1) return -1; - } state = wth->capture.generic = g_malloc(sizeof(pppdump_t)); state->timestamp = pntohl(&buffer[1]); @@ -546,10 +544,8 @@ pppdump_seek_read (wtap *wth, return FALSE; } - if (file_seek(wth->random_fh, pid->offset, SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + if (file_seek(wth->random_fh, pid->offset, SEEK_SET, err) == -1) return FALSE; - } init_state(state->seek_state); diff --git a/wiretap/radcom.c b/wiretap/radcom.c index c603474347..1d6586bec8 100644 --- a/wiretap/radcom.c +++ b/wiretap/radcom.c @@ -1,6 +1,6 @@ /* radcom.c * - * $Id: radcom.c,v 1.36 2002/04/09 08:15:04 guy Exp $ + * $Id: radcom.c,v 1.37 2002/06/07 07:27:35 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -101,10 +101,8 @@ int radcom_open(wtap *wth, int *err) return 0; } - if (file_seek(wth->fh, 0x8B, SEEK_SET) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, 0x8B, SEEK_SET, err) == -1) return -1; - } wth->data_offset = 0x8B; errno = WTAP_ERR_CANT_READ; bytes_read = file_read(&byte, 1, 1, wth->fh); @@ -153,10 +151,8 @@ int radcom_open(wtap *wth, int *err) tm.tm_sec = sec%60; tm.tm_isdst = -1; - if (file_seek(wth->fh, sizeof(struct frame_date), SEEK_CUR) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, sizeof(struct frame_date), SEEK_CUR, err) == -1) return -1; - } wth->data_offset += sizeof(struct frame_date); errno = WTAP_ERR_CANT_READ; @@ -166,10 +162,8 @@ int radcom_open(wtap *wth, int *err) } wth->data_offset += 4; while (memcmp(encap_magic, search_encap, 4)) { - if (file_seek(wth->fh, -3, SEEK_CUR) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, -3, SEEK_CUR, err) == -1) return -1; - } wth->data_offset -= 3; errno = WTAP_ERR_CANT_READ; bytes_read = file_read(search_encap, 1, 4, wth->fh); @@ -178,10 +172,8 @@ int radcom_open(wtap *wth, int *err) } wth->data_offset += 4; } - if (file_seek(wth->fh, 12, SEEK_CUR) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, 12, SEEK_CUR, err) == -1) return -1; - } wth->data_offset += 12; errno = WTAP_ERR_CANT_READ; bytes_read = file_read(search_encap, 1, 4, wth->fh); @@ -206,10 +198,8 @@ int radcom_open(wtap *wth, int *err) } while (memcmp(&start_date, &next_date, 4)) { - if (file_seek(wth->fh, 1-sizeof(struct frame_date), SEEK_CUR) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, 1-sizeof(struct frame_date), SEEK_CUR, err) == -1) return -1; - } errno = WTAP_ERR_CANT_READ; bytes_read = file_read(&next_date, 1, sizeof(struct frame_date), wth->fh); @@ -219,16 +209,12 @@ int radcom_open(wtap *wth, int *err) }*/ if (wth->file_encap == WTAP_ENCAP_ETHERNET) { - if (file_seek(wth->fh, 294, SEEK_CUR) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, 294, SEEK_CUR, err) == -1) return -1; - } wth->data_offset += 294; } else if (wth->file_encap == WTAP_ENCAP_LAPB) { - if (file_seek(wth->fh, 297, SEEK_CUR) == -1) { - *err = file_error(wth->fh); + if (file_seek(wth->fh, 297, SEEK_CUR, err) == -1) return -1; - } wth->data_offset += 297; } @@ -316,10 +302,8 @@ radcom_seek_read(wtap *wth, long seek_off, int ret; struct radcomrec_hdr hdr; - if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - } /* Read record header. */ ret = radcom_read_rec_header(wth->random_fh, &hdr, err); diff --git a/wiretap/snoop.c b/wiretap/snoop.c index 492548cb6c..33817a26b3 100644 --- a/wiretap/snoop.c +++ b/wiretap/snoop.c @@ -1,6 +1,6 @@ /* snoop.c * - * $Id: snoop.c,v 1.51 2002/05/26 21:32:39 guy Exp $ + * $Id: snoop.c,v 1.52 2002/06/07 07:27:35 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -427,10 +427,8 @@ static gboolean snoop_seek_read(wtap *wth, long seek_off, union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err) { - if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - } if (wth->file_encap == WTAP_ENCAP_ATM_SNIFFER) { if (!snoop_read_atm_pseudoheader(wth->random_fh, pseudo_header, diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c index 06d2a9ed47..5bda2a6de2 100644 --- a/wiretap/toshiba.c +++ b/wiretap/toshiba.c @@ -1,6 +1,6 @@ /* toshiba.c * - * $Id: toshiba.c,v 1.23 2002/03/05 08:39:29 guy Exp $ + * $Id: toshiba.c,v 1.24 2002/06/07 07:27:35 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -265,10 +265,8 @@ toshiba_seek_read (wtap *wth, long seek_off, { int pkt_len; - if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1) return FALSE; - } pkt_len = parse_toshiba_rec_hdr(NULL, wth->random_fh, pseudo_header, err); diff --git a/wiretap/visual.c b/wiretap/visual.c index 7e1baf8e90..41dca79594 100644 --- a/wiretap/visual.c +++ b/wiretap/visual.c @@ -2,7 +2,7 @@ * File read and write routines for Visual Networks cap files. * Copyright (c) 2001, Tom Nisbet tnisbet@visualnetworks.com * - * $Id: visual.c,v 1.7 2002/05/04 10:00:18 guy Exp $ + * $Id: visual.c,v 1.8 2002/06/07 07:27:35 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -339,10 +339,8 @@ static gboolean visual_seek_read (wtap *wth, long seek_off, /* Seek to the packet header */ if (file_seek(wth->random_fh, seek_off - sizeof(struct visual_pkt_hdr), - SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + SEEK_SET, err) == -1) return FALSE; - } /* Read the packet header to get the status flags. */ errno = WTAP_ERR_CANT_READ; diff --git a/wiretap/vms.c b/wiretap/vms.c index a77dfa453a..8d9c911b52 100644 --- a/wiretap/vms.c +++ b/wiretap/vms.c @@ -1,6 +1,6 @@ /* vms.c * - * $Id: vms.c,v 1.12 2002/03/25 21:15:54 guy Exp $ + * $Id: vms.c,v 1.13 2002/06/07 07:27:35 guy Exp $ * * Wiretap Library * Copyright (c) 2001 by Marc Milgram <mmilgram@arrayinc.com> @@ -170,9 +170,8 @@ static gboolean vms_check_file_type(wtap *wth, int *err) if (byte == vms_hdr_magic[level]) { level++; if (level >= VMS_HDR_MAGIC_SIZE) { - if (file_seek(wth->fh, mpos, SEEK_SET) == -1) { + if (file_seek(wth->fh, mpos, SEEK_SET, err) == -1) { /* Error. */ - *err = file_error(wth->fh); return FALSE; } return TRUE; @@ -258,10 +257,8 @@ vms_seek_read (wtap *wth, long seek_off, { int pkt_len; - if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET) == -1) { - *err = file_error(wth->random_fh); + if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1) return FALSE; - } pkt_len = parse_vms_rec_hdr(NULL, wth->random_fh, err); |