aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/vms.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/vms.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/vms.c')
-rw-r--r--wiretap/vms.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/wiretap/vms.c b/wiretap/vms.c
index 19af1bfbc1..9b0da71330 100644
--- a/wiretap/vms.c
+++ b/wiretap/vms.c
@@ -1,6 +1,6 @@
/* vms.c
*
- * $Id: vms.c,v 1.8 2002/03/04 00:25:35 guy Exp $
+ * $Id: vms.c,v 1.9 2002/03/05 05:58:41 guy Exp $
*
* Wiretap Library
* Copyright (c) 2001 by Marc Milgram <mmilgram@arrayinc.com>
@@ -73,7 +73,7 @@ static const char vms_hdr_magic[] =
static gboolean vms_read(wtap *wth, int *err, long *data_offset);
static int vms_seek_read(wtap *wth, long seek_off,
- union wtap_pseudo_header *pseudo_header, guint8 *pd, int len);
+ union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err);
static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf, long byte_offset, int in_off, int remaining_bytes);
static int parse_vms_hex_dump(FILE_T fh, int pkt_len, guint8* buf, int *err);
static int parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err);
@@ -219,7 +219,6 @@ static gboolean vms_read(wtap *wth, int *err, long *data_offset)
/* Parse the header */
pkt_len = parse_vms_rec_hdr(wth, wth->fh, err);
-
if (pkt_len == -1)
return FALSE;
@@ -228,7 +227,8 @@ static gboolean vms_read(wtap *wth, int *err, long *data_offset)
buf = buffer_start_ptr(wth->frame_buffer);
/* Convert the ASCII hex dump to binary data */
- parse_vms_hex_dump(wth->fh, pkt_len, buf, err);
+ if (parse_vms_hex_dump(wth->fh, pkt_len, buf, err) == -1)
+ return FALSE;
wth->data_offset = offset;
*data_offset = offset;
@@ -239,20 +239,25 @@ static gboolean vms_read(wtap *wth, int *err, long *data_offset)
static int
vms_seek_read (wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header _U_,
- guint8 *pd, int len)
+ guint8 *pd, int len, int *err)
{
int pkt_len;
- int err;
- file_seek(wth->random_fh, seek_off - 1, SEEK_SET);
+ if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET) == -1) {
+ *err = file_error(wth->random_fh);
+ return -1;
+ }
- pkt_len = parse_vms_rec_hdr(NULL, wth->random_fh, &err);
+ pkt_len = parse_vms_rec_hdr(NULL, wth->random_fh, err);
if (pkt_len != len) {
+ if (pkt_len != -1)
+ *err = WTAP_ERR_BAD_RECORD;
return -1;
}
- parse_vms_hex_dump(wth->random_fh, pkt_len, pd, &err);
+ if (parse_vms_hex_dump(wth->random_fh, pkt_len, pd, err) == -1)
+ return -1;
return 0;
}