aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/iptrace.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-03-05 05:58:41 +0000
committerGuy Harris <guy@alum.mit.edu>2002-03-05 05:58:41 +0000
commite300f4db52ddfcdfbf8a53d69d88e037365cb7a3 (patch)
treeedc94f3db1aa4b8d5dfc6192d153023fb32d9a0d /wiretap/iptrace.c
parenta7553a55864b398593c9e3c922d91ae804e0d732 (diff)
downloadwireshark-e300f4db52ddfcdfbf8a53d69d88e037365cb7a3.tar.gz
wireshark-e300f4db52ddfcdfbf8a53d69d88e037365cb7a3.tar.bz2
wireshark-e300f4db52ddfcdfbf8a53d69d88e037365cb7a3.zip
Have "wtap_seek_read()" return 0 on success and -1 on failure, and take
an "err" argument that points to an "int" into which to put an error code if it fails. Check for errors in one call to it, and note that we should do so in other places. In the "wtap_seek_read()" call in the TCP graphing code, don't overwrite "cfile.pseudo_header", and make the buffer into which we read the data WTAP_MAX_PACKET_SIZE bytes, as it should be. In some of the file readers for text files, check for errors from the "parse the record header" and "parse the hex dump" routines when reading sequentially. In "csids_seek_read()", fix some calls to "file_error()" to check the error on the random stream (that being what we're reading). svn path=/trunk/; revision=4874
Diffstat (limited to 'wiretap/iptrace.c')
-rw-r--r--wiretap/iptrace.c46
1 files changed, 31 insertions, 15 deletions
diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c
index 9b57bb098e..e53442e2a6 100644
--- a/wiretap/iptrace.c
+++ b/wiretap/iptrace.c
@@ -1,6 +1,6 @@
/* iptrace.c
*
- * $Id: iptrace.c,v 1.36 2001/11/13 23:55:43 gram Exp $
+ * $Id: iptrace.c,v 1.37 2002/03/05 05:58:40 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -33,11 +33,13 @@
static gboolean iptrace_read_1_0(wtap *wth, int *err, long *data_offset);
static int iptrace_seek_read_1_0(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size);
+ union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size,
+ int *err);
static gboolean iptrace_read_2_0(wtap *wth, int *err, long *data_offset);
static int iptrace_seek_read_2_0(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size);
+ union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size,
+ int *err);
static int iptrace_read_rec_header(FILE_T fh, guint8 *header, int header_len,
int *err);
@@ -162,19 +164,26 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, long *data_offset)
}
static int iptrace_seek_read_1_0(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size)
+ union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size,
+ int *err)
{
int ret;
- int err; /* XXX - return this */
guint8 header[30];
- file_seek(wth->random_fh, seek_off, SEEK_SET);
+ if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) {
+ *err = file_error(wth->random_fh);
+ return -1;
+ }
/* Read the descriptor data */
- ret = iptrace_read_rec_header(wth->random_fh, header, 30, &err);
+ ret = iptrace_read_rec_header(wth->random_fh, header, 30, err);
if (ret <= 0) {
/* Read error or EOF */
- return ret;
+ if (ret == 0) {
+ /* EOF means "short read" in random-access mode */
+ *err = WTAP_ERR_SHORT_READ;
+ }
+ return -1;
}
if ( wtap_encap_ift(header[28]) == WTAP_ENCAP_ATM_SNIFFER ) {
@@ -182,7 +191,7 @@ static int iptrace_seek_read_1_0(wtap *wth, long seek_off,
}
/* Read the packet data */
- return iptrace_read_rec_data(wth->random_fh, pd, packet_size, &err);
+ return iptrace_read_rec_data(wth->random_fh, pd, packet_size, err);
}
/***********************************************************
@@ -274,19 +283,26 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, long *data_offset)
}
static int iptrace_seek_read_2_0(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size)
+ union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size,
+ int *err)
{
int ret;
- int err; /* XXX - return this */
guint8 header[40];
- file_seek(wth->random_fh, seek_off, SEEK_SET);
+ if (file_seek(wth->random_fh, seek_off, SEEK_SET) == -1) {
+ *err = file_error(wth->random_fh);
+ return -1;
+ }
/* Read the descriptor data */
- ret = iptrace_read_rec_header(wth->random_fh, header, 40, &err);
+ ret = iptrace_read_rec_header(wth->random_fh, header, 40, err);
if (ret <= 0) {
/* Read error or EOF */
- return ret;
+ if (ret == 0) {
+ /* EOF means "short read" in random-access mode */
+ *err = WTAP_ERR_SHORT_READ;
+ }
+ return -1;
}
if ( wtap_encap_ift(header[28]) == WTAP_ENCAP_ATM_SNIFFER ) {
@@ -294,7 +310,7 @@ static int iptrace_seek_read_2_0(wtap *wth, long seek_off,
}
/* Read the packet data */
- return iptrace_read_rec_data(wth->random_fh, pd, packet_size, &err);
+ return iptrace_read_rec_data(wth->random_fh, pd, packet_size, err);
}
static int