(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/netxray.c) |
| |
| 1797 | | | static gboolean netxray_dump_close_2_0(wtap_dumper *wdh, int *err) |
| 1798 | | | { |
| 1799 | | | char hdr_buf[ - sizeof(netxray_magic)]; |
| 1800 | | | netxray_dump_t *netxray = wdh->dump.netxray; |
| 1801 | | | guint32 filelen; |
| 1802 | | | struct netxray_hdr file_hdr; |
| 1803 | | | size_t nwritten; |
| 1804 | | | |
| 1805 | | | filelen = (guint32)ftell(wdh->fh); |
Ignored Return Value
The return value of ftell() 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 ftell(). (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 |
|
| 1806 | | | |
| 1807 | | | |
| 1808 | | | fseek(wdh->fh, 0, SEEK_SET);
x /usr/include/stdio.h |
| |
141 | #define SEEK_SET 0 /* Seek from beginning of file. */ |
| |
|
| 1809 | | | |
| 1810 | | | |
| 1811 | | | nwritten = fwrite(netxray_magic, 1, sizeof netxray_magic, wdh->fh); |
| 1812 | | | if (nwritten != sizeof netxray_magic) { |
Event 2:
Taking true branch. nwritten != sizeof( netxray_magic ) evaluates to true.
hide
|
|
| 1813 | | | if (err != NULL) { |
Event 3:
Taking true branch. err != (void *)0 evaluates to true.
hide
|
|
| 1814 | | | if (nwritten == 0 && ferror(wdh->fh)) |
| 1815 | | | *err = errno; |
| 1816 | | | else |
| 1817 | | | *err = WTAP_ERR_SHORT_WRITE; |
| 1818 | | | } |
| 1819 | | | return FALSE; |
| 1820 | | | } |
| 1821 | | | |
| 1822 | | | |
| 1823 | | | memset(&file_hdr, '\0', sizeof file_hdr); |
| 1824 | | | memcpy(file_hdr.version, vers_2_001, sizeof vers_2_001); |
| 1825 | | | file_hdr.start_time = htolel(netxray->start.secs); |
| 1826 | | | file_hdr.nframes = htolel(netxray->nframes); |
| 1827 | | | file_hdr.start_offset = htolel(); |
| 1828 | | | file_hdr.end_offset = htolel(filelen); |
| 1829 | | | file_hdr.network = wtap_encap_to_netxray_2_0_encap(wdh->encap); |
| 1830 | | | file_hdr.timelo = htolel(0); |
| 1831 | | | file_hdr.timehi = htolel(0); |
| 1832 | | | switch (wdh->encap) { |
| 1833 | | | |
| 1834 | | | case WTAP_ENCAP_PPP_WITH_PHDR: |
| 1835 | | | file_hdr.captype = WAN_CAPTYPE_PPP; |
| 1836 | | | break; |
| 1837 | | | |
| 1838 | | | case WTAP_ENCAP_FRELAY_WITH_PHDR: |
| 1839 | | | file_hdr.captype = WAN_CAPTYPE_FRELAY;
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/netxray.c |
| |
127 | #define WAN_CAPTYPE_FRELAY 4 /* Frame Relay captured with pod */ |
| |
|
| 1840 | | | break; |
| 1841 | | | |
| 1842 | | | case WTAP_ENCAP_LAPB: |
| 1843 | | | file_hdr.captype = WAN_CAPTYPE_HDLC;
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/netxray.c |
| |
129 | #define WAN_CAPTYPE_HDLC 6 /* HDLC (X.25, ISDN) captured with pod */ |
| |
|
| 1844 | | | file_hdr.wan_hdlc_subsub_captype = 0; |
| 1845 | | | break; |
| 1846 | | | |
| 1847 | | | case WTAP_ENCAP_SDLC: |
| 1848 | | | file_hdr.captype = WAN_CAPTYPE_SDLC; |
| 1849 | | | break; |
| 1850 | | | |
| 1851 | | | default: |
| 1852 | | | file_hdr.captype = CAPTYPE_NDIS;
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/netxray.c |
| |
109 | #define CAPTYPE_NDIS 0 /* Capture on network interface using NDIS */ |
| |
|
| 1853 | | | break; |
| 1854 | | | } |
| 1855 | | | |
| 1856 | | | memset(hdr_buf, '\0', sizeof hdr_buf); |
| 1857 | | | memcpy(hdr_buf, &file_hdr, sizeof(file_hdr)); |
| 1858 | | | nwritten = fwrite(hdr_buf, 1, sizeof hdr_buf, wdh->fh); |
| 1859 | | | if (nwritten != sizeof hdr_buf) { |
| 1860 | | | if (err != NULL) { |
| 1861 | | | if (nwritten == 0 && ferror(wdh->fh)) |
| 1862 | | | *err = errno; |
| 1863 | | | else |
| 1864 | | | *err = WTAP_ERR_SHORT_WRITE; |
| 1865 | | | } |
| 1866 | | | return FALSE; |
| 1867 | | | } |
| 1868 | | | |
| 1869 | | | return TRUE; |
| 1870 | | | } |
| |