Text   |  XML   |  ReML   |   Visible Warnings:

Unreachable Control Flow  at print_dlg.c:1066

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

print_ok_cb

(/home/sate/Testcases/c/cve/wireshark-1.2.0/gtk/print_dlg.c)expand/collapse
Show more  
 898  print_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
 899  {
 900    GtkWidget         *button;
 901    print_args_t      *args;
 902    const gchar       *g_dest;
 903    gchar             *f_name;
 904    gchar             *dirname;
 905    gboolean          export_as_pdml = FALSE, export_as_psml = FALSE;
 906    gboolean          export_as_csv = FALSE;
 907    gboolean          export_as_carrays = FALSE;
 908  #ifdef _WIN32 
 909    gboolean          win_printer = FALSE;
 910    int               tmp_fd;
 911    char              tmp_namebuf[128+1];  /* XX: see create_tmpfile which says [128+1]; why ? */
 912    char              *tmp_oldfile;
 913  #endif
 914    cf_print_status_t status;
 915   
 916    args = (print_args_t *)g_object_get_data(G_OBJECT(ok_bt), PRINT_ARGS_KEY);
 917   
 918    /* Check whether the range is valid. */
 919    if (!range_check_validity(&args->range)) {
 920      /* The range isn't valid; don't dismiss the print/export dialog box,
 921         just leave it around so that the user can, after they
 922         dismiss the alert box popped up for the error, try again. */
 923      return;
 924    }
 925   
 926    button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_DEST_CB_KEY);
 927    args->to_file = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button));
 928   
 929    if (args->to_file) {
 930        g_dest = gtk_entry_get_text(GTK_ENTRY(g_object_get_data(G_OBJECT(ok_bt),
 931                                                            PRINT_FILE_TE_KEY)));
 932      if (!g_dest[0]) {
 933        simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
 934          "Output to file, but no file specified.");
 935        return;
 936      }
 937      g_free(args->file);
 938      args->file = g_strdup(g_dest);
 939      /* Save the directory name for future file dialogs. */
 940      f_name = g_strdup(g_dest);
 941      dirname = get_dirname(f_name);  /* Overwrites f_name */
 942      set_last_open_dir(dirname);
 943      g_free(f_name);
 944    } else {
 945  #ifdef _WIN32 
 946      win_printer = TRUE;
 947      /* We currently don't have a function in util.h to create just a tempfile */
 948      /* name, so simply create a tempfile using the "official" function,       */
 949      /* then delete this file again. After this, the name MUST be available.   */
 950      /* */
 951      /* Don't use tmpnam() or such, as this will fail under some ACL           */
 952      /* circumstances: http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=358  */
 953      /* Also: tmpnam is "insecure" and should not be used.                     */
 954      tmp_fd = create_tempfile(tmp_namebuf, sizeof(tmp_namebuf), "wshprint");
 955      if(tmp_fd == -1) {
 956          simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
 957              "Couldn't create a temporary file for printing.");
 958          return;
 959      }
 960      /* remember to restore these values later! */
 961      tmp_oldfile = args->file;
 962      args->file = g_strdup(tmp_namebuf);
 963      ws_unlink(args->file);
 964      args->to_file = TRUE;
 965  #else
 966      g_free(args->cmd);
 967      args->cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(g_object_get_data(G_OBJECT(ok_bt),
 968        PRINT_CMD_TE_KEY))));
 969  #endif
 970    }
 971   
 972    args->format = PR_FMT_TEXT;
 973    button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_PS_RB_KEY);
 974    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button)))
 975      args->format = PR_FMT_PS;
 976    button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_PDML_RB_KEY);
 977    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button)))
 978      export_as_pdml = TRUE;
 979    button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_PSML_RB_KEY);
 980    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button)))
 981      export_as_psml = TRUE;
 982    button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_CSV_RB_KEY);
 983    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button)))
 984      export_as_csv = TRUE;
 985    button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_CARRAYS_RB_KEY);
 986    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button)))
 987      export_as_carrays = TRUE;
 988   
 989    button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_SUMMARY_CB_KEY);
 990    args->print_summary = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button));
 991   
 992    button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_COLLAPSE_ALL_RB_KEY);
 993    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button))) {
 994      args->print_dissections = print_dissections_collapsed;
 995    }
 996    button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_AS_DISPLAYED_RB_KEY);
 997    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button))) {
 998      args->print_dissections = print_dissections_as_displayed;
 999    }
 1000    button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_EXPAND_ALL_RB_KEY);
 1001    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button))) {
 1002      args->print_dissections = print_dissections_expanded;
 1003    }
 1004   
 1005    /* the details setting has priority over the radio buttons */
 1006    button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_DETAILS_CB_KEY);
 1007    if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button))) {
 1008      args->print_dissections = print_dissections_none;
 1009    }
 1010   
 1011    button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_HEX_CB_KEY);
 1012    args->print_hex = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button));
 1013   
 1014    button = (GtkWidget *)g_object_get_data(G_OBJECT(ok_bt), PRINT_FORMFEED_CB_KEY);
 1015    args->print_formfeed = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button));
 1016   
 1017   
 1018    window_destroy(GTK_WIDGET(parent_w));
 1019   
 1020    /* Now print/export the packets */
 1021    if (export_as_pdml)
 1022      status = cf_write_pdml_packets(&cfile, args);
 1023    else if (export_as_psml)
 1024      status = cf_write_psml_packets(&cfile, args);
 1025    else if (export_as_csv)
 1026      status = cf_write_csv_packets(&cfile, args);
 1027    else if (export_as_carrays)
 1028      status = cf_write_carrays_packets(&cfile, args);
 1029    else {
 1030      switch (args->format) {
 1031   
 1032      case PR_FMT_TEXT:
 1033        if (args->to_file) {
 1034          args->stream = print_stream_text_new(TRUE, args->file);
 1035          if (args->stream == NULL) {
 1036            open_failure_alert_box(args->file, errno, TRUE);
 1037            return;
 1038          }
 1039        } else {
 1040          args->stream = print_stream_text_new(FALSE, args->cmd);
 1041          if (args->stream == NULL) {
 1042            simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
 1043                          "Couldn't run print command %s.", args->cmd);
 1044          }
 1045        }
 1046        break;
 1047   
 1048      case PR_FMT_PS:
 1049        if (args->to_file) {
 1050          args->stream = print_stream_ps_new(TRUE, args->file);
 1051          if (args->stream == NULL) {
 1052            open_failure_alert_box(args->file, errno, TRUE);
 1053            return;
 1054          }
 1055        } else {
 1056          args->stream = print_stream_ps_new(FALSE, args->cmd);
 1057          if (args->stream == NULL) {
 1058            simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
 1059                          "Couldn't run print command %s.", args->cmd);
 1060          }
 1061        }
 1062        break;
 1063   
 1064      default:
 1065        g_assert_not_reached();
 1066        return;
 1067      }
 1068      status = cf_print_packets(&cfile, args);
 1069    }
 1070    switch (status) {
 1071   
 1072    case CF_PRINT_OK:
 1073      break;
 1074   
 1075    case CF_PRINT_OPEN_ERROR:
 1076      if (args->to_file)
 1077        open_failure_alert_box(args->file, errno, TRUE);
 1078      else 
 1079        simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Couldn't run print command %s.",
 1080          args->cmd);
 1081      break;
 1082   
 1083    case CF_PRINT_WRITE_ERROR:
 1084      if (args->to_file)
 1085        write_failure_alert_box(args->file, errno);
 1086      else 
 1087        simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
 1088          "Error writing to print command: %s", strerror(errno));
 1089      break;
 1090    }
 1091   
 1092  #ifdef _WIN32 
 1093    if (win_printer) {
 1094      print_mswin(args->file);
 1095   
 1096      /* trash temp file */
 1097      ws_remove(args->file);
 1098      g_free(args->file);
 1099   
 1100      /* restore old settings */
 1101      args->to_file = FALSE;
 1102      args->file = tmp_oldfile;
 1103    }
 1104  #endif
 1105  }
Show more  




Change Warning 4232.30732 : Unreachable Control Flow

Priority:
State:
Finding:
Owner:
Note: