Graeme Hewson noted that zlib has a bug wherein "gzseek()" doesn't set
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 7 Jun 2002 07:27:35 +0000 (07:27 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 7 Jun 2002 07:27:35 +0000 (07:27 +0000)
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

21 files changed:
wiretap/ascend.c
wiretap/csids.c
wiretap/dbs-etherwatch.c
wiretap/etherpeek.c
wiretap/file.c
wiretap/file_wrappers.c
wiretap/file_wrappers.h
wiretap/i4btrace.c
wiretap/iptrace.c
wiretap/lanalyzer.c
wiretap/libpcap.c
wiretap/netmon.c
wiretap/nettl.c
wiretap/netxray.c
wiretap/ngsniffer.c
wiretap/pppdump.c
wiretap/radcom.c
wiretap/snoop.c
wiretap/toshiba.c
wiretap/visual.c
wiretap/vms.c

index 6710cadece7a389b5c9b81f0f46c4dede6e253fa..f3f97388f1974c263a1f491613e7ef3a00d972ee 100644 (file)
@@ -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;
index fd830246d84636ceaadb8cf2283395ea4d2557b9..ce819a71d3dc30d31f96a3528dc97c5a832d49e2 100644 (file)
@@ -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) ) {
index fbe3d582fd7ddf770da1ab835998b12830d28f0d..66a81232e6e5bc84e4e7228404cf6000ec2030cb 100644 (file)
@@ -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);
 
index ee55db7405dce58da47ec0822f851167f3c78a1c..5818ffce9491c2c076493581d5940b3355bb57d7 100644 (file)
@@ -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) {
                /*
index 178a1092378f0eeb73e036c7188d12f01853f25b..973cc948213b691d3fc9009df4fcaef0bdad21c4 100644 (file)
@@ -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);
index c69a00daacd0f2cd773de8b282352a5fc8154499..ae8a98706d21a1535434e589e91810c3c03c9c52 100644 (file)
@@ -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>
 
 #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 */
 
 /*
index efeb96e35a81d7f54064c441a8d09ecd79847b58..ee29c7a3bfaf53ac678d5aebb62fc0d8dbeaed92 100644 (file)
@@ -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
index 9b9eec20667379ef5a1a9617ef57db678faf0677..1ed623fd16358ef2558a3a17c022b610b0f5b178 100644 (file)
@@ -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);
index bbd89ddba3fd969d5f6a04bdab30ba671855d7ca..945d842cdf796f446ec8f645ead32cbc5faea103 100644 (file)
@@ -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);
index 6372e99c03ec1c13264aa4fbb13fcac2347b8d9f..45b5e5b8f0f29e7bba85e99b328aeff1d65d2617 100644 (file)
@@ -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;
                                }
index 7702c387b28a941bcf974afd8b560f34850165ef..57fb13453c24ac2ea7348cdd308fc9e25b56335d 100644 (file)
@@ -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,
index 6268840d1ee7981222db129b50ccbbc4dd156198..3de968242c9f1886c7bc9c0bd445461675c75849 100644 (file)
@@ -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,
index 14bc109059f02797613e3ca586930df49a5231eb..9780ffed301cbe6f58a4f64d6000aa716d29af0d 100644 (file)
@@ -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,
index 545fb1cc97cbbf752f3b74eecc1c596307f31d11..1500e92dde7da2506be51d09b5d7863789122043 100644 (file)
@@ -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) {
index e3e50f5dacbe12238fa13c2474441cbfc37adc50..219f8ec4697c27e3b01c671154e3f6914eaec151 100644 (file)
@@ -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;
index d11aeaf6bd9ebe47e6023c901262b9a504b9ea1e..d267ea914aa0f949270fbcab7a081dd8b7f88acd 100644 (file)
@@ -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);
 
index c603474347a9e10de5748012fb330c302611e232..1d6586bec87e10e3939a724d19d6e53d480d565a 100644 (file)
@@ -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);
index 492548cb6cb62a8a618c99bc79c5a0c3d1662357..33817a26b3c2223715d2bead7a288b07fcaaaa6f 100644 (file)
@@ -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,
index 06d2a9ed470fab805111b83f83b799adbe7a699c..5bda2a6de20c0de677dae155c02956409cee44e8 100644 (file)
@@ -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);
index 7e1baf8e90d57cc038877e76a3494dc6e8f36ed5..41dca795948976aa77833592d0e954ea931380f9 100644 (file)
@@ -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;
index a77dfa453a92c6f4ec668881f38a59779a5e4f0f..8d9c911b5266f64a36b9d01897b8d3a9c3036c1a 100644 (file)
@@ -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);