(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/netxray.c) |
| |
| 1587 | | | static gboolean netxray_dump_close_1_1(wtap_dumper *wdh, int *err) |
| 1588 | | | { |
| 1589 | | | char hdr_buf[ - sizeof(netxray_magic)]; |
| 1590 | | | netxray_dump_t *netxray = wdh->dump.netxray; |
| 1591 | | | guint32 filelen; |
| 1592 | | | struct netxray_hdr file_hdr; |
| 1593 | | | size_t nwritten; |
| 1594 | | | |
| 1595 | | | 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 |
|
| 1596 | | | |
| 1597 | | | |
| 1598 | | | fseek(wdh->fh, 0, SEEK_SET);
x /usr/include/stdio.h |
| |
141 | #define SEEK_SET 0 /* Seek from beginning of file. */ |
| |
|
| 1599 | | | |
| 1600 | | | |
| 1601 | | | nwritten = fwrite(netxray_magic, 1, sizeof netxray_magic, wdh->fh); |
| 1602 | | | if (nwritten != sizeof netxray_magic) { |
Event 2:
Taking true branch. nwritten != sizeof( netxray_magic ) evaluates to true.
hide
|
|
| 1603 | | | if (err != NULL) { |
Event 3:
Taking true branch. err != (void *)0 evaluates to true.
hide
|
|
| 1604 | | | if (nwritten == 0 && ferror(wdh->fh)) |
| 1605 | | | *err = errno; |
| 1606 | | | else |
| 1607 | | | *err = WTAP_ERR_SHORT_WRITE; |
| 1608 | | | } |
| 1609 | | | return FALSE; |
| 1610 | | | } |
| 1611 | | | |
| 1612 | | | |
| 1613 | | | memset(&file_hdr, '\0', sizeof file_hdr); |
| 1614 | | | memcpy(file_hdr.version, vers_1_1, sizeof vers_1_1); |
| 1615 | | | file_hdr.start_time = htolel(netxray->start.secs); |
| 1616 | | | file_hdr.nframes = htolel(netxray->nframes); |
| 1617 | | | file_hdr.start_offset = htolel(); |
| 1618 | | | file_hdr.end_offset = htolel(filelen); |
| 1619 | | | file_hdr.network = wtap_encap_to_netxray_1_1_encap(wdh->encap); |
| 1620 | | | file_hdr.timelo = htolel(0); |
| 1621 | | | file_hdr.timehi = htolel(0); |
| 1622 | | | |
| 1623 | | | memset(hdr_buf, '\0', sizeof hdr_buf); |
| 1624 | | | memcpy(hdr_buf, &file_hdr, sizeof(file_hdr)); |
| 1625 | | | nwritten = fwrite(hdr_buf, 1, sizeof hdr_buf, wdh->fh); |
| 1626 | | | if (nwritten != sizeof hdr_buf) { |
| 1627 | | | if (err != NULL) { |
| 1628 | | | if (nwritten == 0 && ferror(wdh->fh)) |
| 1629 | | | *err = errno; |
| 1630 | | | else |
| 1631 | | | *err = WTAP_ERR_SHORT_WRITE; |
| 1632 | | | } |
| 1633 | | | return FALSE; |
| 1634 | | | } |
| 1635 | | | |
| 1636 | | | return TRUE; |
| 1637 | | | } |
| |