aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-09-28 18:03:20 +0000
committerGuy Harris <guy@alum.mit.edu>2013-09-28 18:03:20 +0000
commita582b7201ae75b15ba8e9ce600a33c0ec0737003 (patch)
tree632c1d54ba2f806a18dbd56e38af8d6f8dcee9ac /wiretap
parent12912b657b052f8a04be058a6c7115c076204b3f (diff)
In a Simple Packet Block, the captured length isn't the block length
minus the lengths of the two length fields and the packet length field, it's the minimum of that and the packet length, as there might be padding. Fixes one problem found by the file in bug 9200. While we're at it, pcapng_read_packet_block() and pcapng_read_simple_packet_block() return an integer, not a Boolean; return 0, not FALSE (they have the same value, but returning 0 makes it clearer that the return value isn't restricted to TRUE or FALSE). svn path=/trunk/; revision=52241
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/pcapng.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c
index a657207bac..b0fc3c2dc9 100644
--- a/wiretap/pcapng.c
+++ b/wiretap/pcapng.c
@@ -1114,7 +1114,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("pcapng: interface index %u is not less than interface count %u.",
wblock->data.packet.interface_id, pn->number_of_interfaces);
- return FALSE;
+ return 0;
}
int_data = g_array_index(pn->interface_data, interface_data_t,
wblock->data.packet.interface_id);
@@ -1138,7 +1138,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
err,
err_info);
if (pseudo_header_len < 0) {
- return FALSE;
+ return 0;
}
block_read += pseudo_header_len;
if (pseudo_header_len != pcap_get_phdr_size(int_data.wtap_encap, &wblock->packet_header->pseudo_header)) {
@@ -1157,7 +1157,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
errno = WTAP_ERR_CANT_READ;
if (!wtap_read_packet_bytes(fh, wblock->frame_buffer,
wblock->data.packet.cap_len - pseudo_header_len, err, err_info))
- return FALSE;
+ return 0;
block_read += wblock->data.packet.cap_len - pseudo_header_len;
/* jump over potential padding bytes at end of the packet data */
@@ -1338,6 +1338,8 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *
wblock->data.simple_packet.cap_len = bh->block_total_length
- (guint32)sizeof(pcapng_simple_packet_block_t)
- (guint32)sizeof(bh->block_total_length);
+ if (wblock->data.simple_packet.cap_len > wblock->data.simple_packet.packet_len)
+ wblock->data.simple_packet.cap_len = wblock->data.simple_packet.packet_len;
if (wblock->data.simple_packet.cap_len > WTAP_MAX_PACKET_SIZE) {
*err = WTAP_ERR_BAD_FILE;
@@ -1352,7 +1354,7 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("pcapng: interface index 0 is not less than interface count %u.",
pn->number_of_interfaces);
- return FALSE;
+ return 0;
}
int_data = g_array_index(pn->interface_data, interface_data_t, 0);
@@ -1396,7 +1398,7 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *
errno = WTAP_ERR_CANT_READ;
if (!wtap_read_packet_bytes(fh, wblock->frame_buffer,
wblock->data.simple_packet.cap_len, err, err_info))
- return FALSE;
+ return 0;
block_read += wblock->data.simple_packet.cap_len;
/* jump over potential padding bytes at end of the packet data */