Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at filesystem.c:1602

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            /* They're on different file systems, so we have to copy the
 3555               file. */
 3556            do_copy = TRUE;
 3557            from_filename = cf->filename;
 3558          } else {
 3559            /* The rename failed, but not because they're on different
 3560               file systems - put up an error message.  (Or should we
 3561               just punt and try to copy?  The only reason why I'd
 3562               expect the rename to fail and the copy to succeed would
 3563               be if we didn't have permission to remove the file from 
 3564               the temporary directory, and that might be fixable - but 
 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))
expand/collapse

copy_file_binary_mode

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/filesystem.c)expand/collapse
Show more  
 1596  copy_file_binary_mode(const char *from_filename, const char *to_filename)
 1597  {
 1598    int           from_fd, to_fd, nread, nwritten, err;
 1599    guint8        pd[65536];
 1600   
 1601    /* Copy the raw bytes of the file. */
 1602    from_fd = ws_open(from_filename, O_RDONLY | O_BINARY, 0000 /* no creation so don't matter */);
Show more  
Show more  




Change Warning 3975.31771 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: