aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/vwr.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-09-13 22:13:59 -0700
committerGuy Harris <guy@alum.mit.edu>2017-09-14 05:14:31 +0000
commitf3cf2ffd3af2b9d6315c19473bc1091bfe71b89c (patch)
treef78890ad7036dc0bf612f8f275852cc4af1c60d0 /wiretap/vwr.c
parent9e905abe54bdc5a9409cd4b6f340909ae1bb3b91 (diff)
Move a test.
If we're not going to subtract 4 from actual_octets, there's no reason to treat actual_octets < 4 as an error. This makes the "subtract 4 octets of crap" code similar in all cases, hopefully further reducing the opacity of the code. Change-Id: I41cda101b321422ce5fd4474fb6903bfe471cb63 Reviewed-on: https://code.wireshark.org/review/23534 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/vwr.c')
-rw-r--r--wiretap/vwr.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/wiretap/vwr.c b/wiretap/vwr.c
index 5883c98f92..9312a283de 100644
--- a/wiretap/vwr.c
+++ b/wiretap/vwr.c
@@ -2112,29 +2112,32 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr,
* lsb nibble is set to 1 always as this function is applicable for only FPGA version >= 48
*/
if (log_mode == 3) {
- /*
- * The MSDU length includes the FCS.
- *
- * The packet data does *not* include the FCS - it's just 4 bytes
- * of junk - so we have to remove it.
- *
- * We'll be stripping off that junk, so make sure we have at
- * least 4 octets worth of packet data.
- *
- * XXX - is the FCS actually present here, as it appears to be
- * if log_mode isn't 3?
- *
- * There seems to be a special case of a length of 0.
- */
- if (actual_octets < 4) {
- if (actual_octets != 0) {
- *err_info = g_strdup_printf("vwr: Invalid data length %u (too short to include 4 bytes of FCS)",
- actual_octets);
- *err = WTAP_ERR_BAD_FILE;
- return FALSE;
+ if (frame_size >= (int) msdu_length) {
+ /*
+ * The MSDU length includes the FCS.
+ *
+ * The packet data does *not* include the FCS - it's just 4
+ * bytes of junk - so we have to remove it.
+ *
+ * We'll be stripping off that junk, so make sure we have at
+ * least 4 octets worth of packet data.
+ *
+ * XXX - is the FCS actually present here, as it appears to be
+ * if log_mode isn't 3?
+ *
+ * There seems to be a special case of a length of 0.
+ */
+ if (actual_octets < 4) {
+ if (actual_octets != 0) {
+ *err_info = g_strdup_printf("vwr: Invalid data length %u (too short to include 4 bytes of FCS)",
+ actual_octets);
+ *err = WTAP_ERR_BAD_FILE;
+ return FALSE;
+ }
+ } else {
+ actual_octets -= 4;
}
- } else if (frame_size >= (int) msdu_length)
- actual_octets -= 4;
+ }
ver_fpga = 0x11;
} else {
ver_fpga = 0x01;