Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at file_access.c:982

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
3576
Show [ Lines 3550 to 3576 omitted. ]
 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);
expand/collapse

wtap_dump_open

(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_access.c)expand/collapse
Show more  
 742  wtap_dumper* wtap_dump_open(const char *filename, int filetype, int encap,
 743                                  int snaplen, gboolean compressed, int *err)
 744  {
 745          wtap_dumper *wdh;
 746          FILE *fh;
 747   
 748          /* Check whether we can open a capture file with that file type
 749             and that encapsulation. */
 750[+]         if (!wtap_dump_open_check(filetype, encap, compressed, err))
 751                  return NULL;
 752   
 753          /* Allocate a data structure for the output stream. */
 754[+]         wdh = wtap_dump_alloc_wdh(filetype, encap, snaplen, compressed, err);
 755          if (wdh == NULL)
 756                  return NULL;    /* couldn't allocate it */
 757   
 758          /* "-" means stdout */
 759          if (strcmp(filename, "-") == 0) {
 760                  if(compressed) {
 761                          g_free(wdh);
 762                          return NULL;    /* compress won't work on stdout */
 763                  }
 764  #ifdef _WIN32 
 765                  setmode(fileno(stdout), O_BINARY);
 766  #endif
 767                  wdh->fh = stdout;
 768          } else {
 769                  /* In case "fopen()" fails but doesn't set "errno", set "errno"
 770                     to a generic "the open failed" error. */
 771                  errno = WTAP_ERR_CANT_OPEN;
 772[+]                 fh = wtap_dump_file_open(wdh, filename);
expand/collapse

wtap_dump_file_open

(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_access.c)expand/collapse
Show more  
 977  static FILE *wtap_dump_file_open(wtap_dumper *wdh, const char *filename)
 978  {
 979          if(wdh->compressed) {
 980                  return gzopen(filename, "wb");
 981          } else {
 982                  return ws_fopen(filename, "wb");
Show more  
Show more  
Show more  




Change Warning 3971.31767 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: