Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at file_access.c:235

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

cf_save

(/home/sate/Testcases/c/cve/wireshark-1.2.0/file.c)expand/collapse
Show more  
 3516  cf_save(capture_file *cf, const char *fname, packet_range_t *range, guint save_format, gboolean compressed)
 3517  {
 3518    gchar        *from_filename;
 3519    int           err;
 3520    gboolean      do_copy;
 3521    wtap_dumper  *pdh;
 3522    save_callback_args_t callback_args;
 3523   
 3524    cf_callback_invoke(cf_cb_file_safe_started, (gpointer) fname);
 3525   
 3526    /* don't write over an existing file. */
 3527    /* this should've been already checked by our caller, just to be sure... */
 3528[+]   if (file_exists(fname)) {
 3529      simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
 3530        "%sCapture file: \"%s\" already exists!%s\n\n"
 3531        "Please choose a different filename.",
 3532        simple_dialog_primary_start(), fname, simple_dialog_primary_end());
 3533      goto fail;
 3534    }
 3535   
 3536    packet_range_process_init(range);
 3537   
 3538   
 3539    if (packet_range_process_all(range) && save_format == cf->cd_t) {
 3540      /* We're not filtering packets, and we're saving it in the format 
 3541         it's already in, so we can just move or copy the raw data. */
 3542   
 3543      if (cf->is_tempfile) {
 3544        /* The file being saved is a temporary file from a live 
 3545           capture, so it doesn't need to stay around under that name;
 3546           first, try renaming the capture buffer file to the new name. */
 3547  #ifndef _WIN32 
 3548        if (ws_rename(cf->filename, fname) == 0) {
 3549          /* That succeeded - there's no need to copy the source file. */
 3550          from_filename = NULL;
 3551          do_copy = FALSE;
 3552        } else {
 3553          if (errno == EXDEV) {
 3554
3564
Show [ Lines 3554 to 3564 omitted. ]
 3565               is it worth requiring the user to go off and fix it?) */
 3566            simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
 3567                                  file_rename_error_message(errno), fname);
 3568            goto fail;
 3569          }
 3570        }
 3571  #else
 3572        do_copy = TRUE;
 3573        from_filename = cf->filename;
 3574  #endif
 3575      } else {
 3576        /* It's a permanent file, so we should copy it, and not remove the
 3577           original. */
 3578        do_copy = TRUE;
 3579        from_filename = cf->filename;
 3580      }
 3581   
 3582      if (do_copy) {
 3583        /* Copy the file, if we haven't moved it. */
 3584[+]       if (!copy_file_binary_mode(from_filename, fname))
 3585          goto fail;
 3586      }
 3587    } else {
 3588      /* Either we're filtering packets, or we're saving in a different
 3589         format; we can't do that by copying or moving the capture file,
 3590         we have to do it by writing the packets out in Wiretap. */
 3591      pdh = wtap_dump_open(fname, save_format, cf->lnk_t, cf->snap,
 3592                  compressed, &err);
 3593      if (pdh == NULL) {
 3594        cf_open_failure_alert_box(fname, err, NULL, TRUE, save_format);
 3595
3626
Show [ Lines 3595 to 3626 omitted. ]
 3627        wtap_dump_close(pdh, &err);
 3628        goto fail;
 3629      }
 3630   
 3631      if (!wtap_dump_close(pdh, &err)) {
 3632        cf_close_failure_alert_box(fname, err);
 3633        goto fail;
 3634      }
 3635    }
 3636   
 3637    cf_callback_invoke(cf_cb_file_safe_finished, NULL);
 3638   
 3639[+]   if (packet_range_process_all(range)) {
 3640      /* We saved the entire capture, not just some packets from it.
 3641         Open and read the file we saved it to.
 3642   
 3643         XXX - this is somewhat of a waste; we already have the
 3644         packets, all this gets us is updated file type information 
 3645         (which we could just stuff into "cf"), and having the new
 3646         file be the one we have opened and from which we're reading 
 3647         the data, and it means we have to spend time opening and
 3648         reading the file, which could be a significant amount of 
 3649         time if the file is large. */
 3650      cf->user_saved = TRUE;
 3651   
 3652[+]     if ((cf_open(cf, fname, FALSE, &err)) == CF_OK) {
expand/collapse

cf_open

(/home/sate/Testcases/c/cve/wireshark-1.2.0/file.c)expand/collapse
Show more  
 228  cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
 229  {
 230    wtap       *wth;
 231    gchar       *err_info;
 232   
 233[+]   wth = wtap_open_offline(fname, err, &err_info, TRUE);
expand/collapse

wtap_open_offline

(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_access.c)expand/collapse
Show more  
 216  wtap* wtap_open_offline(const char *filename, int *err, char **err_info,
 217                          gboolean do_random)
 218  {
 219          struct stat statb;
 220          wtap    *wth;
 221          unsigned int    i;
 222          gboolean use_stdin = FALSE;
 223   
 224          /* open standard input if filename is '-' */
 225          if (strcmp(filename, "-") == 0)
 226                  use_stdin = TRUE;
 227   
 228          /* First, make sure the file is valid */
 229          if (use_stdin) {
 230                  if (fstat(0, &statb) < 0) {
 231                          *err = errno;
 232                          return NULL;
 233                  }
 234          } else {
 235                  if (ws_stat(filename, &statb) < 0) {
Show more  
Show more  
Show more  




Change Warning 3973.31769 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: