aboutsummaryrefslogtreecommitdiffstats
path: root/file.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 /file.c
parenta7553a55864b398593c9e3c922d91ae804e0d732 (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). svn path=/trunk/; revision=4874
Diffstat (limited to 'file.c')
-rw-r--r--file.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/file.c b/file.c
index c2155ce9a7..4576514b39 100644
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
- * $Id: file.c,v 1.264 2002/02/27 08:57:14 guy Exp $
+ * $Id: file.c,v 1.265 2002/03/05 05:58:27 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -898,6 +898,7 @@ rescan_packets(capture_file *cf, const char *action, gboolean refilter,
guint32 progbar_quantum;
guint32 progbar_nextstep;
unsigned int count;
+ int err;
frame_data *selected_frame;
int selected_row;
int row;
@@ -1000,8 +1001,9 @@ rescan_packets(capture_file *cf, const char *action, gboolean refilter,
free_data_sources(fdata); /* release data source list */
}
+ /* XXX - do something with "err" */
wtap_seek_read (cf->wth, fdata->file_off, &cf->pseudo_header,
- cf->pd, fdata->cap_len);
+ cf->pd, fdata->cap_len, &err);
row = add_packet_to_packet_list(fdata, cf, &cf->pseudo_header, cf->pd,
refilter);
@@ -1058,6 +1060,7 @@ print_packets(capture_file *cf, print_args_t *print_args)
guint32 progbar_quantum;
guint32 progbar_nextstep;
guint32 count;
+ int err;
gint *col_widths = NULL;
gint data_width;
gboolean print_separator;
@@ -1172,8 +1175,9 @@ print_packets(capture_file *cf, print_args_t *print_args)
*/
if (((print_args->suppress_unmarked && fdata->flags.marked ) ||
!(print_args->suppress_unmarked)) && fdata->flags.passed_dfilter) {
+ /* XXX - do something with "err" */
wtap_seek_read (cf->wth, fdata->file_off, &cf->pseudo_header,
- cf->pd, fdata->cap_len);
+ cf->pd, fdata->cap_len, &err);
if (print_args->print_summary) {
/* Fill in the column information, but don't bother creating
the logical protocol tree. */
@@ -1374,6 +1378,7 @@ find_packet(capture_file *cf, dfilter_t *sfcode)
guint32 progbar_quantum;
guint32 progbar_nextstep;
unsigned int count;
+ int err;
gboolean frame_matched;
int row;
epan_dissect_t *edt;
@@ -1438,8 +1443,9 @@ find_packet(capture_file *cf, dfilter_t *sfcode)
/* Is this packet in the display? */
if (fdata->flags.passed_dfilter) {
/* Yes. Does it match the search filter? */
+ /* XXX - do something with "err" */
wtap_seek_read(cf->wth, fdata->file_off, &cf->pseudo_header,
- cf->pd, fdata->cap_len);
+ cf->pd, fdata->cap_len, &err);
edt = epan_dissect_new(TRUE, FALSE);
epan_dissect_prime_dfilter(edt, sfcode);
epan_dissect_run(edt, &cf->pseudo_header, cf->pd, fdata, NULL);
@@ -1503,6 +1509,7 @@ void
select_packet(capture_file *cf, int row)
{
frame_data *fdata;
+ int err;
/* Get the frame data struct pointer for this frame */
fdata = (frame_data *) gtk_clist_get_row_data(GTK_CLIST(packet_list), row);
@@ -1542,8 +1549,9 @@ select_packet(capture_file *cf, int row)
cf->current_frame = fdata;
/* Get the data in that frame. */
+ /* XXX - do something with "err" */
wtap_seek_read (cf->wth, fdata->file_off, &cf->pseudo_header,
- cf->pd, fdata->cap_len);
+ cf->pd, fdata->cap_len, &err);
/* Create the logical protocol tree. */
if (cf->edt != NULL) {
@@ -1783,8 +1791,13 @@ save_cap_file(char *fname, capture_file *cf, gboolean save_filtered, gboolean sa
hdr.caplen = fdata->cap_len;
hdr.len = fdata->pkt_len;
hdr.pkt_encap = fdata->lnk_t;
- wtap_seek_read(cf->wth, fdata->file_off, &pseudo_header,
- pd, fdata->cap_len);
+ if (wtap_seek_read(cf->wth, fdata->file_off, &pseudo_header,
+ pd, fdata->cap_len, &err) == -1) {
+ simple_dialog(ESD_TYPE_CRIT, NULL,
+ file_read_error_message(err), cf->filename);
+ wtap_dump_close(pdh, &err);
+ goto done;
+ }
if (!wtap_dump(pdh, &hdr, &pseudo_header, pd, &err)) {
simple_dialog(ESD_TYPE_CRIT, NULL,