Text   |  XML   |  ReML   |   Visible Warnings:

Unused Value  at dumpcap.c:1924

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

capture_loop_open_output

(/home/sate/Testcases/c/cve/wireshark-1.2.0/dumpcap.c)expand/collapse
Show more  
 1834  capture_loop_open_output(capture_options *capture_opts, int *save_file_fd,
 1835                        char *errmsg, int errmsg_len) {
 1836   
 1837    char tmpname[128+1];
 1838    gchar *capfile_name;
 1839    gboolean is_tempfile;
 1840  #ifndef _WIN32 
 1841    int ret;
 1842  #endif
 1843   
 1844    g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "capture_loop_open_output: %s",
 1845        (capture_opts->save_file) ? capture_opts->save_file : "");
 1846   
 1847    if (capture_opts->save_file != NULL) {
 1848      /* We return to the caller while the capture is in progress.
 1849       * Therefore we need to take a copy of save_file in
 1850       * case the caller destroys it after we return.
 1851       */
 1852      capfile_name = g_strdup(capture_opts->save_file);
 1853   
 1854      if (capture_opts->output_to_pipe == TRUE) { /* either "-" or named pipe */
 1855        if (capture_opts->multi_files_on) {
 1856          /* ringbuffer is enabled; that doesn't work with standard output or a named pipe */
 1857          g_snprintf(errmsg, errmsg_len,
 1858              "Ring buffer requested, but capture is being written to standard output or to a named pipe.");
 1859          g_free(capfile_name);
 1860          return FALSE;
 1861        }
 1862        if (strcmp(capfile_name, "-") == 0) {
 1863          /* write to stdout */
 1864          *save_file_fd = 1;
 1865  #ifdef _WIN32 
 1866          /* set output pipe to binary mode to avoid Windows text-mode processing (eg: for CR/LF)  */
 1867          _setmode(1, O_BINARY);
 1868  #endif
 1869        }
 1870      } /* if (...output_to_pipe ... */
 1871   
 1872      else {
 1873        if (capture_opts->multi_files_on) {
 1874          /* ringbuffer is enabled */
 1875          *save_file_fd = ringbuf_init(capfile_name,
 1876              (capture_opts->has_ring_num_files) ? capture_opts->ring_num_files : 0);
 1877   
 1878          /* we need the ringbuf name */
 1879          if(*save_file_fd != -1) {
 1880              g_free(capfile_name);
 1881              capfile_name = g_strdup(ringbuf_current_filename());
 1882          }
 1883        } else {
 1884          /* Try to open/create the specified file for use as a capture buffer. */
 1885          *save_file_fd = ws_open(capfile_name, O_RDWR|O_BINARY|O_TRUNC|O_CREAT,
 1886                               0600);
 1887        }
 1888      }
 1889      is_tempfile = FALSE;
 1890    } else {
 1891      /* Choose a random name for the temporary capture buffer */
 1892      *save_file_fd = create_tempfile(tmpname, sizeof tmpname, "wireshark");
 1893      capfile_name = g_strdup(tmpname);
 1894      is_tempfile = TRUE;
 1895    }
 1896   
 1897    /* did we fail to open the output file? */
 1898    if (*save_file_fd == -1) {
 1899      if (is_tempfile) {
 1900        g_snprintf(errmsg, errmsg_len,
 1901          "The temporary file to which the capture would be saved (\"%s\") "
 1902          "could not be opened: %s.", capfile_name, strerror(errno));
 1903      } else {
 1904        if (capture_opts->multi_files_on) {
 1905          ringbuf_error_cleanup();
 1906        }
 1907   
 1908        g_snprintf(errmsg, errmsg_len,
 1909              "The file to which the capture would be saved (\"%s\") "
 1910          "could not be opened: %s.", capfile_name,
 1911          strerror(errno));
 1912      }
 1913      g_free(capfile_name);
 1914      return FALSE;
 1915    }
 1916   
 1917    if(capture_opts->save_file != NULL) {
 1918      g_free(capture_opts->save_file);
 1919    }
 1920    capture_opts->save_file = capfile_name;
 1921    /* capture_opts.save_file is "g_free"ed later, which is equivalent to
 1922       "g_free(capfile_name)". */
 1923  #ifndef _WIN32 
 1924    ret = fchown(*save_file_fd, capture_opts->owner, capture_opts->group);
 1925  #endif
 1926   
 1927    return TRUE;
 1928  }
Show more  




Change Warning 5030.30307 : Unused Value

Priority:
State:
Finding:
Owner:
Note: