(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/pcapng.c) |
| |
| 826 | | | pcapng_read_simple_packet_block(FILE_T fh, *bh, pcapng_t *pn, wtapng_block_t *wblock,int *err, gchar **err_info _U_) |
| 827 | | | { |
| 828 | | | int bytes_read; |
| 829 | | | int block_read; |
| 830 | | | guint64 file_offset64; |
| 831 | | | pcapng_simple_packet_block_t spb; |
| 832 | | | |
| 833 | | | |
| 834 | | | |
| 835 | | | errno = WTAP_ERR_CANT_READ; |
| 836 | | | bytes_read = file_read(&spb, 1, sizeof spb, fh);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 837 | | | if (bytes_read != sizeof spb) { |
| 838 | | | pcapng_debug0("pcapng_read_simple_packet_block: failed to read packet data"); |
| 839 | | | *err = file_error(fh); |
| 840 | | | return 0; |
| 841 | | | } |
| 842 | | | block_read = bytes_read; |
| 843 | | | |
| 844 | | | if(pn->byte_swapped) { |
| 845 | | | wblock->data.simple_packet.packet_len = BSWAP32(spb.packet_len);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
297 | #define BSWAP32(x) \ |
298 | ((((x)&0xFF000000)>>24) | \ |
299 | (((x)&0x00FF0000)>>8) | \ |
300 | (((x)&0x0000FF00)<<8) | \ |
301 | (((x)&0x000000FF)<<24)) |
| |
|
| 846 | | | } else { |
| 847 | | | wblock->data.simple_packet.packet_len = spb.packet_len; |
| 848 | | | } |
| 849 | | | |
| 850 | | | wblock->data.simple_packet.cap_len = bh->block_total_length |
| 851 | | | - (guint32)sizeof(pcapng_simple_packet_block_t) |
| 852 | | | - (guint32)sizeof(bh->block_total_length); |
| 853 | | | |
| 854 | | | |
| 855 | | | |
| 856 | | | |
| 857 | | | |
| 858 | | | |
| 859 | | | |
| 860 | | | |
| 861 | | | ((union *) wblock->)->eth.fcs_len = pn->if_fcslen; |
| 862 | | | |
| 863 | | | |
| 864 | | | errno = WTAP_ERR_CANT_READ; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 865 | | | bytes_read = file_read((guchar *) (wblock->frame_buffer), 1, wblock->data.simple_packet.cap_len, fh);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 866 | | | if (bytes_read != (int) wblock->data.simple_packet.cap_len) { |
| 867 | | | *err = file_error(fh); |
| 868 | | | pcapng_debug1("pcapng_read_simple_packet_block: couldn't read %u bytes of captured data", |
| 869 | | | wblock->data.simple_packet.cap_len); |
| 870 | | | if (*err == 0) |
| 871 | | | *err = WTAP_ERR_SHORT_READ; |
| 872 | | | return FALSE; |
| 873 | | | } |
| 874 | | | block_read += bytes_read; |
| 875 | | | |
| 876 | | | |
| 877 | | | if( (wblock->data.simple_packet.cap_len % 4) != 0) { |
| 878 | | | file_offset64 = file_seek(fh, 4 - (wblock->data.simple_packet.cap_len % 4), SEEK_CUR, err);
x /usr/include/stdio.h |
| |
142 | #define SEEK_CUR 1 /* Seek from current position. */ |
| |
|
| 879 | | | if (file_offset64 <= 0) { |
| 880 | | | if (*err != 0) |
| 881 | | | return -1; |
| 882 | | | return 0; |
| 883 | | | } |
| 884 | | | block_read += 4 - (wblock->data.simple_packet.cap_len % 4); |
| 885 | | | } |
| 886 | | | |
| 887 | | | return block_read; |
| 888 | | | } |
| |