(/home/sate/Testcases/c/cve/wireshark-1.2.0/dumpcap.c) |
| |
| 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",
x /home/sate/Testcases/c/cve/wireshark-1.2.0/log.h |
| |
32 | #define LOG_DOMAIN_CAPTURE_CHILD "CaptureChild" |
| |
|
| 1845 | | | (capture_opts->save_file) ? capture_opts->save_file : ""); |
| 1846 | | | |
| 1847 | | | if (capture_opts->save_file != NULL) { |
| 1848 | | | |
| 1849 | | | |
| 1850 | | | |
| 1851 | | | |
| 1852 | | | capfile_name = g_strdup(capture_opts->save_file); |
| 1853 | | | |
| 1854 | | | if (capture_opts->output_to_pipe == TRUE) { |
| 1855 | | | if (capture_opts->multi_files_on) { |
| 1856 | | | |
| 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 | | | |
| 1864 | | | *save_file_fd = 1; |
| 1865 | | | #ifdef _WIN32 |
| 1866 | | | |
| 1867 | | | _setmode(1, O_BINARY); |
| 1868 | | | #endif |
| 1869 | | | } |
| 1870 | | | } |
| 1871 | | | |
| 1872 | | | else { |
| 1873 | | | if (capture_opts->multi_files_on) { |
| 1874 | | | |
| 1875 | | | *save_file_fd = ringbuf_init(capfile_name, |
| 1876 | | | (capture_opts->has_ring_num_files) ? capture_opts->ring_num_files : 0); |
| 1877 | | | |
| 1878 | | | |
| 1879 | | | if(*save_file_fd != -1) { |
| 1880 | | | g_free(capfile_name); |
| 1881 | | | capfile_name = g_strdup(ringbuf_current_filename()); |
| 1882 | | | } |
| 1883 | | | } else { |
| 1884 | | | |
| 1885 | | | *save_file_fd = ws_open(capfile_name, O_RDWR|O_BINARY|O_TRUNC|O_CREAT,
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wsutil/file_util.h |
| |
105 | #define O_BINARY 0 /* Win32 needs the O_BINARY flag for open() */ |
| |
x /usr/include/bits/fcntl.h |
| |
41 | #define O_TRUNC 01000 /* not fcntl */ |
| |
x /usr/include/bits/fcntl.h |
| |
38 | #define O_CREAT 0100 /* not fcntl */ |
| |
|
| 1886 | | | 0600); |
| 1887 | | | } |
| 1888 | | | } |
| 1889 | | | is_tempfile = FALSE; |
| 1890 | | | } else { |
| 1891 | | | |
| 1892 | | | *save_file_fd = create_tempfile(tmpname, sizeof tmpname, "wireshark"); |
| 1893 | | | capfile_name = g_strdup(tmpname); |
| 1894 | | | is_tempfile = TRUE; |
| 1895 | | | } |
| 1896 | | | |
| 1897 | | | |
| 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 | | | |
| 1922 | | | |
| 1923 | | | #ifndef _WIN32 |
| 1924 | | | ret = fchown(*save_file_fd, capture_opts->owner, capture_opts->group); |
Ignored Return Value
The return value of fchown() is never checked in the highlighted execution scenario. - If the return value can indicate an error, the error will be ignored if the highlighted code executes.
- CodeSonar is configured to enforce Ignored Return Value checks for fchown(). (To change the set of enforced Ignored Return Value checks, use configuration file parameters RETURN_CHECKER_CHECKED_FUNCS and RETURN_CHECKER_IGNORED_FUNCS).
Show: All events | Only primary events |
|
| 1925 | | | #endif |
| 1926 | | | |
| 1927 | | | return TRUE; |
Event 2:
!0 evaluates to true.
hide
|
|
| 1928 | | | } |
| |