Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at filesystem.c:1613

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))
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 */);
 1603    if (from_fd < 0) {
 1604      report_open_failure(from_filename, errno, FALSE);
 1605      goto done;
 1606    }
 1607   
 1608    /* Use open() instead of creat() so that we can pass the O_BINARY 
 1609       flag, which is relevant on Win32; it appears that "creat()"
 1610       may open the file in text mode, not binary mode, but we want 
 1611       to copy the raw bytes of the file, so we need the output file
 1612       to be open in binary mode. */
 1613    to_fd = ws_open(to_filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
Show more  
Show more  




Change Warning 3972.31768 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: