diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-12-17 16:41:21 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-12-18 00:41:43 +0000 |
commit | 6011a047d3cd2aba84e7fdd3bf7e8403a2f3563b (patch) | |
tree | e65e862bc54c08528399d081c5d4d2df128a2b5d | |
parent | aa27e665b1d469e54b8cbb9931d5324acdf4dc75 (diff) |
WTAP_ERR_UNWRITABLE_ errors aren't returned by reads or open-for-reading.
Check for them *only* on opening for writing and writes.
Change-Id: I4b537d511ec04bcfc81f69166a2b9a2ee9310067
Reviewed-on: https://code.wireshark.org/review/5827
Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r-- | capinfos.c | 4 | ||||
-rw-r--r-- | capture_info.c | 11 | ||||
-rw-r--r-- | captype.c | 2 | ||||
-rw-r--r-- | editcap.c | 4 | ||||
-rw-r--r-- | file.c | 38 | ||||
-rw-r--r-- | frame_tvbuff.c | 2 | ||||
-rw-r--r-- | mergecap.c | 4 | ||||
-rw-r--r-- | rawshark.c | 6 | ||||
-rw-r--r-- | reordercap.c | 6 | ||||
-rw-r--r-- | tshark.c | 20 |
10 files changed, 9 insertions, 88 deletions
diff --git a/capinfos.c b/capinfos.c index 7c98f33b6d..785818741d 100644 --- a/capinfos.c +++ b/capinfos.c @@ -905,10 +905,8 @@ process_cap_file(wtap *wth, const char *filename) break; case WTAP_ERR_UNSUPPORTED: - case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: case WTAP_ERR_DECOMPRESS: - case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); /* fallthrough */ @@ -1486,10 +1484,8 @@ main(int argc, char *argv[]) switch (err) { case WTAP_ERR_UNSUPPORTED: - case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: case WTAP_ERR_DECOMPRESS: - case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; diff --git a/capture_info.c b/capture_info.c index 6f45f5489c..753bba0e80 100644 --- a/capture_info.c +++ b/capture_info.c @@ -144,15 +144,8 @@ cf_open_error_message(int err, gchar *err_info, gboolean for_writing, break; case WTAP_ERR_UNWRITABLE_ENCAP: - if (for_writing) - errmsg = "Wireshark can't save this capture in that format."; - else { - g_snprintf(errmsg_errno, sizeof(errmsg_errno), - "The file \"%%s\" is a capture for a network type that Wireshark doesn't support.\n" - "(%s)", err_info); - g_free(err_info); - errmsg = errmsg_errno; - } + /* Seen only when opening a capture file for writing. */ + errmsg = "Wireshark can't save this capture in that format."; break; case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED: @@ -257,9 +257,7 @@ main(int argc, char *argv[]) switch (err) { case WTAP_ERR_UNSUPPORTED: - case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: - case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; @@ -1251,9 +1251,7 @@ main(int argc, char *argv[]) wtap_strerror(err)); switch (err) { case WTAP_ERR_UNSUPPORTED: - case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: - case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; @@ -1718,9 +1716,7 @@ main(int argc, char *argv[]) argv[optind], wtap_strerror(err)); switch (err) { case WTAP_ERR_UNSUPPORTED: - case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: - case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; @@ -747,13 +747,6 @@ cf_read(capture_file *cf, gboolean reloading) g_free(err_info); break; - case WTAP_ERR_UNWRITABLE_ENCAP: - simple_error_message_box( - "The capture file has a packet with a network type that Wireshark doesn't support.\n(%s)", - err_info); - g_free(err_info); - break; - case WTAP_ERR_SHORT_READ: simple_error_message_box( "The capture file appears to have been cut short" @@ -1526,13 +1519,6 @@ cf_merge_files(char **out_filenamep, int in_file_count, display_basename = g_filename_display_basename(in_files[i].filename); switch (read_err) { - case WTAP_ERR_UNWRITABLE_ENCAP: - simple_error_message_box( - "The capture file %s has a packet with a network type that Wireshark doesn't support.\n(%s)", - display_basename, err_info); - g_free(err_info); - break; - case WTAP_ERR_SHORT_READ: simple_error_message_box( "The capture file %s appears to have been cut short" @@ -1758,12 +1744,6 @@ cf_read_record_r(capture_file *cf, const frame_data *fdata, display_basename = g_filename_display_basename(cf->filename); switch (err) { - case WTAP_ERR_UNWRITABLE_ENCAP: - simple_error_message_box("The file \"%s\" has a packet with a network type that Wireshark doesn't support.\n(%s)", - display_basename, err_info); - g_free(err_info); - break; - case WTAP_ERR_BAD_FILE: simple_error_message_box("An error occurred while reading from the file \"%s\": %s.\n(%s)", display_basename, wtap_strerror(err), err_info); @@ -4543,13 +4523,6 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err) g_free(err_info); break; - case WTAP_ERR_UNWRITABLE_ENCAP: - simple_error_message_box( - "The capture file has a packet with a network type that Wireshark doesn't support.\n(%s)", - err_info); - g_free(err_info); - break; - case WTAP_ERR_SHORT_READ: simple_error_message_box( "The capture file appears to have been cut short" @@ -5082,15 +5055,8 @@ cf_open_failure_alert_box(const char *filename, int err, gchar *err_info, break; case WTAP_ERR_UNWRITABLE_ENCAP: - if (for_writing) { - simple_error_message_box("Wireshark can't save this capture in that format."); - } else { - simple_error_message_box( - "The file \"%s\" is a capture for a network type that Wireshark doesn't support.\n" - "(%s)", - display_basename, err_info); - g_free(err_info); - } + /* Seen only when opening a capture file for writing. */ + simple_error_message_box("Wireshark can't save this capture in that format."); break; case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED: diff --git a/frame_tvbuff.c b/frame_tvbuff.c index c8d2f83a68..cc02722283 100644 --- a/frame_tvbuff.c +++ b/frame_tvbuff.c @@ -58,8 +58,8 @@ frame_read(struct tvb_frame *frame_tvb, struct wtap_pkthdr *phdr, Buffer *buf) * frame_tvb->tvb.length + frame_tvb->offset? */ if (!wtap_seek_read(frame_tvb->wth, frame_tvb->file_off, phdr, buf, &err, &err_info)) { + /* XXX - report error! */ switch (err) { - case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: g_free(err_info); break; diff --git a/mergecap.c b/mergecap.c index cdf2cbe1bc..82b26403e7 100644 --- a/mergecap.c +++ b/mergecap.c @@ -377,9 +377,7 @@ main(int argc, char *argv[]) switch (open_err) { case WTAP_ERR_UNSUPPORTED: - case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: - case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; @@ -547,9 +545,7 @@ main(int argc, char *argv[]) switch (read_err) { case WTAP_ERR_UNSUPPORTED: - case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: - case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; diff --git a/rawshark.c b/rawshark.c index bcd9281082..0fc46c05c4 100644 --- a/rawshark.c +++ b/rawshark.c @@ -1012,12 +1012,6 @@ load_cap_file(capture_file *cf) g_free(err_info); break; - case WTAP_ERR_UNWRITABLE_ENCAP: - cmdarg_err("The file \"%s\" has a packet with a network type that Rawshark doesn't support.\n(%s)", - cf->filename, err_info); - g_free(err_info); - break; - case WTAP_ERR_SHORT_READ: cmdarg_err("The file \"%s\" appears to have been cut short in the middle of a packet.", cf->filename); diff --git a/reordercap.c b/reordercap.c index 72099cf467..b36bc58b40 100644 --- a/reordercap.c +++ b/reordercap.c @@ -124,9 +124,7 @@ frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh, switch (err) { case WTAP_ERR_UNSUPPORTED: - case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: - case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; @@ -298,9 +296,7 @@ main(int argc, char *argv[]) switch (err) { case WTAP_ERR_UNSUPPORTED: - case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: - case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; @@ -356,9 +352,7 @@ main(int argc, char *argv[]) switch (err) { case WTAP_ERR_UNSUPPORTED: - case WTAP_ERR_UNWRITABLE_ENCAP: case WTAP_ERR_BAD_FILE: - case WTAP_ERR_UNWRITABLE_REC_DATA: fprintf(stderr, "(%s)\n", err_info); g_free(err_info); break; @@ -3469,12 +3469,6 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type, g_free(err_info); break; - case WTAP_ERR_UNWRITABLE_ENCAP: - cmdarg_err("The file \"%s\" has a packet with a network type that TShark doesn't support.\n(%s)", - cf->filename, err_info); - g_free(err_info); - break; - case WTAP_ERR_SHORT_READ: cmdarg_err("The file \"%s\" appears to have been cut short in the middle of a packet.", cf->filename); @@ -4224,16 +4218,10 @@ cf_open_error_message(int err, gchar *err_info, gboolean for_writing, break; case WTAP_ERR_UNWRITABLE_ENCAP: - if (for_writing) { - g_snprintf(errmsg_errno, sizeof(errmsg_errno), - "TShark can't save this capture as a \"%s\" file.", - wtap_file_type_subtype_short_string(file_type)); - } else { - g_snprintf(errmsg_errno, sizeof(errmsg_errno), - "The file \"%%s\" is a capture for a network type that TShark doesn't support.\n" - "(%s)", err_info); - g_free(err_info); - } + /* Seen only when opening a capture file for writing. */ + g_snprintf(errmsg_errno, sizeof(errmsg_errno), + "TShark can't save this capture as a \"%s\" file.", + wtap_file_type_subtype_short_string(file_type)); errmsg = errmsg_errno; break; |