aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/file.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2001-03-10 06:33:58 +0000
committerGuy Harris <guy@alum.mit.edu>2001-03-10 06:33:58 +0000
commita251addb63587c5e064bcc58422c0951c4dc4c97 (patch)
treec5e776c62f153404ad4617c940bafc4c4fb4d74f /wiretap/file.c
parent9b1133892b4a545eb142ce4529a53de353f41410 (diff)
Obliging every capture file reader's "open()" routine to seek to the
beginning of the file before reading anything from the file is bogus - do that in the loop that tries each of the open routines, instead. (They may have to reset the seek pointer later if, for example, the capture file begins with the first packet, and the "open()" routine looks at that packet to try to guess whether the packet is in the file format in question.) Set "wth->data_offset" to 0 while you're at it, so capture file readers don't have to do that, either. svn path=/trunk/; revision=3123
Diffstat (limited to 'wiretap/file.c')
-rw-r--r--wiretap/file.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/wiretap/file.c b/wiretap/file.c
index 2e1dbd0eb8..6eba00d993 100644
--- a/wiretap/file.c
+++ b/wiretap/file.c
@@ -1,6 +1,6 @@
/* file.c
*
- * $Id: file.c,v 1.65 2001/03/09 07:11:38 guy Exp $
+ * $Id: file.c,v 1.66 2001/03/10 06:33:57 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@@ -208,6 +208,15 @@ wtap* wtap_open_offline(const char *filename, int *err, gboolean do_random)
/* Try all file types */
for (i = 0; i < N_FILE_TYPES; i++) {
+ /* Seek back to the beginning of the file; the open routine
+ for the previous file type may have left the file
+ position somewhere other than the beginning, and the
+ open routine for this file type will probably want
+ to start reading at the beginning.
+
+ Initialize the data offset while we're at it. */
+ file_seek(wth->fh, 0, SEEK_SET);
+ wth->data_offset = 0;
switch ((*open_routines[i])(wth, err)) {
case -1: