(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/visual.c) |
| |
| 830 | | | static gboolean visual_dump_close(wtap_dumper *wdh, int *err) |
| 831 | | | { |
| 832 | | | struct visual_write_info * visual = wdh->dump.opaque; |
| 833 | | | size_t n_to_write; |
| 834 | | | size_t nwritten; |
| 835 | | | struct visual_file_hdr vfile_hdr; |
| 836 | | | const char *magicp; |
| 837 | | | size_t magic_size; |
| 838 | | | |
| 839 | | | |
| 840 | | | |
| 841 | | | if (visual == 0) |
| 842 | | | return FALSE; |
| 843 | | | |
| 844 | | | |
| 845 | | | if (visual->index_table) |
| 846 | | | { |
| 847 | | | |
| 848 | | | n_to_write = visual->index_table_index * sizeof *visual->index_table; |
| 849 | | | nwritten = fwrite(visual->index_table, 1, n_to_write, wdh->fh); |
| 850 | | | if (nwritten != n_to_write) |
| 851 | | | { |
| 852 | | | if (err != NULL) |
| 853 | | | { |
| 854 | | | if (nwritten == 0 && ferror(wdh->fh)) |
| 855 | | | *err = errno; |
| 856 | | | else |
| 857 | | | *err = WTAP_ERR_SHORT_WRITE; |
| 858 | | | } |
| 859 | | | visual_dump_free(wdh); |
| 860 | | | return FALSE; |
| 861 | | | } |
| 862 | | | } |
| 863 | | | |
| 864 | | | |
| 865 | | | fseek(wdh->fh, 0, SEEK_SET);
x /usr/include/stdio.h |
| |
141 | #define SEEK_SET 0 /* Seek from beginning of file. */ |
| |
|
Ignored Return Value
The return value of fseek() 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 fseek(). (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 |
|
| 866 | | | magicp = visual_magic; |
| 867 | | | magic_size = sizeof visual_magic; |
| 868 | | | nwritten = fwrite(magicp, 1, magic_size, wdh->fh); |
| 869 | | | if (nwritten != magic_size) |
Event 2:
Skipping " if". nwritten != magic_size evaluates to false.
hide
|
|
| 870 | | | { |
| 871 | | | if (err != NULL) |
| 872 | | | { |
| 873 | | | if (nwritten == 0 && ferror(wdh->fh)) |
| 874 | | | *err = errno; |
| 875 | | | else |
| 876 | | | *err = WTAP_ERR_SHORT_WRITE; |
| 877 | | | } |
| 878 | | | visual_dump_free(wdh); |
| 879 | | | return FALSE; |
| 880 | | | } |
| 881 | | | |
| 882 | | | |
| 883 | | | memset(&vfile_hdr, '\0', sizeof vfile_hdr); |
| 884 | | | vfile_hdr.num_pkts = htolel(visual->index_table_index); |
| 885 | | | vfile_hdr.start_time = htolel(visual->start_time); |
| 886 | | | vfile_hdr.max_length = htoles(65535); |
| 887 | | | vfile_hdr.file_flags = htoles(1); |
| 888 | | | vfile_hdr.file_version = htoles(1); |
| 889 | | | g_strlcpy(vfile_hdr.description, "Wireshark file", 64); |
| 890 | | | |
| 891 | | | |
| 892 | | | switch (wdh->encap) |
Event 3:
wdh->encap evaluates to 4.
hide
|
|
| 893 | | | { |
| 894 | | | case WTAP_ENCAP_ETHERNET: |
| 895 | | | vfile_hdr.media_type = htoles(6); |
| 896 | | | break; |
| 897 | | | |
| 898 | | | case WTAP_ENCAP_TOKEN_RING: |
| 899 | | | vfile_hdr.media_type = htoles(9); |
| 900 | | | break; |
| 901 | | | |
| 902 | | | case WTAP_ENCAP_LAPB: |
| 903 | | | vfile_hdr.media_type = htoles(16); |
| 904 | | | break; |
| 905 | | | |
| 906 | | | case WTAP_ENCAP_PPP: |
| 907 | | | case WTAP_ENCAP_PPP_WITH_PHDR: |
| 908 | | | case WTAP_ENCAP_CHDLC_WITH_PHDR: |
| 909 | | | vfile_hdr.media_type = htoles(22); |
| 910 | | | break; |
| 911 | | | |
| 912 | | | case WTAP_ENCAP_FRELAY_WITH_PHDR: |
| 913 | | | vfile_hdr.media_type = htoles(32); |
| 914 | | | break; |
| 915 | | | } |
| 916 | | | |
| 917 | | | |
| 918 | | | nwritten = fwrite(&vfile_hdr, 1, sizeof vfile_hdr, wdh->fh); |
| 919 | | | if (nwritten != sizeof vfile_hdr) |
Event 4:
Taking true branch. nwritten != sizeof( vfile_hdr ) evaluates to true.
hide
|
|
| 920 | | | { |
| 921 | | | if (err != NULL) |
Event 5:
Taking true branch. err != (void *)0 evaluates to true.
hide
|
|
| 922 | | | { |
| 923 | | | if (nwritten == 0 && ferror(wdh->fh)) |
| 924 | | | *err = errno; |
| 925 | | | else |
| 926 | | | *err = WTAP_ERR_SHORT_WRITE; |
| 927 | | | } |
| 928 | | | visual_dump_free(wdh); |
| 929 | | | return FALSE; |
| 930 | | | } |
| 931 | | | |
| 932 | | | |
| 933 | | | visual_dump_free(wdh); |
| 934 | | | return TRUE; |
| 935 | | | } |
| |