aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/i4btrace.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2002-03-05 05:58:41 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2002-03-05 05:58:41 +0000
commitba95ac6c6e371b82f1f91eef869c91b097510ec7 (patch)
treeedc94f3db1aa4b8d5dfc6192d153023fb32d9a0d /wiretap/i4btrace.c
parenta059dca44b7026f03d8b4376b93ed09c255aaf7b (diff)
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). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4874 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'wiretap/i4btrace.c')
-rw-r--r--wiretap/i4btrace.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c
index 0d5dec1c50..0565cdae52 100644
--- a/wiretap/i4btrace.c
+++ b/wiretap/i4btrace.c
@@ -1,6 +1,6 @@
/* i4btrace.c
*
- * $Id: i4btrace.c,v 1.17 2002/03/04 00:25:35 guy Exp $
+ * $Id: i4btrace.c,v 1.18 2002/03/05 05:58:40 guy Exp $
*
* Wiretap Library
* Copyright (c) 1999 by Bert Driehuis <driehuis@playbeing.org>
@@ -34,7 +34,7 @@
static gboolean i4btrace_read(wtap *wth, int *err, long *data_offset);
static int i4btrace_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, u_char *pd, int length);
+ union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err);
static int i4b_read_rec_header(FILE_T fh, i4b_trace_hdr_t *hdr, int *err);
static void i4b_byte_swap_header(wtap *wth, i4b_trace_hdr_t *hdr);
static int i4b_read_rec_data(FILE_T fh, u_char *pd, int length, int *err);
@@ -225,19 +225,25 @@ static gboolean i4btrace_read(wtap *wth, int *err, long *data_offset)
static int
i4btrace_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, u_char *pd, int length)
+ union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err)
{
int ret;
- int err; /* XXX - return this */
i4b_trace_hdr_t hdr;
- 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 record header. */
- ret = i4b_read_rec_header(wth->random_fh, &hdr, &err);
+ ret = i4b_read_rec_header(wth->random_fh, &hdr, 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;
}
i4b_byte_swap_header(wth, &hdr);
@@ -246,7 +252,7 @@ i4btrace_seek_read(wtap *wth, long seek_off,
/*
* Read the packet data.
*/
- return i4b_read_rec_data(wth->random_fh, pd, length, &err);
+ return i4b_read_rec_data(wth->random_fh, pd, length, err);
}
static int