From 50b3da03ca80404f9f1f411407c316bdfa0ea485 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 14 Mar 2014 19:47:22 -0700 Subject: More use of vwr->STATS_LEN to clarify what code is doing. Change-Id: I9292f7b054f7b71727409deb062200a0301db5ee Reviewed-on: https://code.wireshark.org/review/665 Reviewed-by: Guy Harris --- wiretap/vwr.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'wiretap/vwr.c') diff --git a/wiretap/vwr.c b/wiretap/vwr.c index 74ac374ed7..e662016c2a 100644 --- a/wiretap/vwr.c +++ b/wiretap/vwr.c @@ -1115,10 +1115,15 @@ static int parse_s1_W_stats(vwr_t *vwr, struct wtap_pkthdr *phdr, guint8 *rec, else octets = 0; - /* Sanity check the octets field to determine if it is OK (or segfaults result). */ - /* iff it's greater, then truncate to actual record size. */ - if (octets > (rec_size - 64)) - octets = (rec_size - 64); + /* + * Sanity check the octets field to determine if it's greater than + * the packet data available in the record - i.e., the record size + * minus the length of the statistics block. + * + * Truncate it if it is. + */ + if (octets > (rec_size - vwr->STATS_LEN)) + octets = (rec_size - vwr->STATS_LEN); msdu_length = octets; -- cgit v1.2.3