summaryrefslogtreecommitdiff
path: root/wiretap/pppdump.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/pppdump.c
parenta7553a55864b398593c9e3c922d91ae804e0d732 (diff)
downloadwireshark-e300f4db52ddfcdfbf8a53d69d88e037365cb7a3.tar.gz
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/pppdump.c')
-rw-r--r--wiretap/pppdump.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c
index 950c4e4e02..0988e1ef8f 100644
--- a/wiretap/pppdump.c
+++ b/wiretap/pppdump.c
@@ -1,6 +1,6 @@
/* pppdump.c
*
- * $Id: pppdump.c,v 1.15 2002/03/04 00:25:35 guy Exp $
+ * $Id: pppdump.c,v 1.16 2002/03/05 05:58:40 guy Exp $
*
* Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu>
*
@@ -95,7 +95,7 @@ typedef enum {
static gboolean pppdump_read(wtap *wth, int *err, long *data_offset);
static int pppdump_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);
typedef struct {
long offset;
@@ -513,6 +513,7 @@ collate(pppdump_t* state, FILE_T fh, int *err, guint8 *pd, int *num_bytes,
}
+ *err = file_error(fh);
return FALSE;
}
@@ -524,9 +525,9 @@ pppdump_seek_read (wtap *wth,
long seek_off,
union wtap_pseudo_header *pseudo_header,
guint8 *pd,
- int len)
+ int len,
+ int *err)
{
- int err = 0;
int num_bytes;
direction_enum direction;
gboolean retval;
@@ -539,16 +540,20 @@ pppdump_seek_read (wtap *wth,
pid = g_ptr_array_index(state->pids, seek_off);
if (!pid) {
+ *err = WTAP_ERR_BAD_RECORD; /* XXX - better error? */
return -1;
}
- file_seek(wth->random_fh, pid->offset, SEEK_SET);
+ if (file_seek(wth->random_fh, pid->offset, SEEK_SET) == -1) {
+ *err = file_error(wth->random_fh);
+ return -1;
+ }
init_state(state->seek_state);
for (i = 0 ; i <= pid->num_saved_states; i++) {
again:
- retval = collate(state->seek_state, wth->random_fh, &err, pd, &num_bytes,
+ retval = collate(state->seek_state, wth->random_fh, err, pd, &num_bytes,
&direction, NULL);
if (!retval) {
@@ -561,6 +566,7 @@ pppdump_seek_read (wtap *wth,
}
if (len != num_bytes) {
+ *err = WTAP_ERR_BAD_RECORD; /* XXX - better error? */
return -1;
}