summaryrefslogtreecommitdiff
path: root/wiretap
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-05-04 00:12:07 -0700
committerGuy Harris <guy@alum.mit.edu>2017-05-04 07:12:47 +0000
commit4ca15be3eb1f3675d7f683e0b9b433999835dccc (patch)
tree869a3ff79185f830d71dde66f0b0cc99077b3fc5 /wiretap
parentdead1b3817d3992cbce0d5c3c7b3928f44e7e207 (diff)
downloadwireshark-4ca15be3eb1f3675d7f683e0b9b433999835dccc.tar.gz
Do packet length checks iff they're necessary.
They're not necessary for most hardware; remove the unnecessary checks, and add comments indicating why they're not necessary (or fix the "maximum value of actual_octets is" part of the comment). They *are* necessary for Series III hardware; put in the check. Change-Id: Idd64a74099d5cf7398a2ddb850442e53c9206724 Reviewed-on: https://code.wireshark.org/review/21491 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/vwr.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/wiretap/vwr.c b/wiretap/vwr.c
index 23b276ec7a..10695f49a1 100644
--- a/wiretap/vwr.c
+++ b/wiretap/vwr.c
@@ -1227,7 +1227,7 @@ static gboolean vwr_read_s1_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr,
*
* We include the length of the metadata headers in the packet lengths.
*
- * The maximum value of actual_octets is 65535, which, even after
+ * The maximum value of actual_octets is 8191, which, even after
* adding the lengths of the metadata headers, is less than
* WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check it.
*/
@@ -1615,20 +1615,13 @@ static gboolean vwr_read_s2_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr,
* Fill up the per-packet header.
*
* We include the length of the metadata headers in the packet lengths.
+ *
+ * The maximum value of actual_octets is 8191, which, even after
+ * adding the lengths of the metadata headers, is less than
+ * WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check it.
*/
phdr->len = STATS_COMMON_FIELDS_LEN + EXT_WLAN_FIELDS_LEN + actual_octets;
phdr->caplen = STATS_COMMON_FIELDS_LEN + EXT_WLAN_FIELDS_LEN + actual_octets;
- if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
- /*
- * Probably a corrupt capture file; return an error,
- * so that our caller doesn't blow up trying to allocate
- * space for an immensely-large packet.
- */
- *err_info = g_strdup_printf("vwr: File has %u-byte packet, bigger than maximum of %u",
- phdr->caplen, WTAP_MAX_PACKET_SIZE);
- *err = WTAP_ERR_BAD_FILE;
- return FALSE;
- }
phdr->ts.secs = (time_t)s_sec;
phdr->ts.nsecs = (int)(s_usec * 1000);
@@ -2092,6 +2085,17 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr,
phdr->len = OCTO_TIMESTAMP_FIELDS_LEN + OCTO_LAYER1TO4_LEN + actual_octets;
phdr->caplen = OCTO_TIMESTAMP_FIELDS_LEN + OCTO_LAYER1TO4_LEN + actual_octets;
}
+ if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
+ /*
+ * Probably a corrupt capture file; return an error,
+ * so that our caller doesn't blow up trying to allocate
+ * space for an immensely-large packet.
+ */
+ *err_info = g_strdup_printf("vwr: File has %u-byte packet, bigger than maximum of %u",
+ phdr->caplen, WTAP_MAX_PACKET_SIZE);
+ *err = WTAP_ERR_BAD_FILE;
+ return FALSE;
+ }
phdr->ts.secs = (time_t)s_sec;
phdr->ts.nsecs = (int)(s_usec * 1000);
@@ -2478,12 +2482,6 @@ static gboolean vwr_read_rec_data_ethernet(vwr_t *vwr, struct wtap_pkthdr *phdr,
return FALSE;
}
- /*
- * The maximum value of actual_octets is 65535, which, even after
- * adding the lengths of the metadata headers, is less than
- * WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check it.
- */
-
vc_id = pntoh16(&s_ptr[vwr->VCID_OFF]) & vwr->VCID_MASK;
flow_seq = s_ptr[vwr->FLOWSEQ_OFF];
frame_type = pntoh32(&s_ptr[vwr->FRAME_TYPE_OFF]);
@@ -2596,6 +2594,10 @@ static gboolean vwr_read_rec_data_ethernet(vwr_t *vwr, struct wtap_pkthdr *phdr,
* Fill up the per-packet header.
*
* We include the length of the metadata headers in the packet lengths.
+ *
+ * The maximum value of actual_octets is 65535, which, even after
+ * adding the lengths of the metadata headers, is less than
+ * WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check it.
*/
phdr->len = STATS_COMMON_FIELDS_LEN + EXT_ETHERNET_FIELDS_LEN + actual_octets;
phdr->caplen = STATS_COMMON_FIELDS_LEN + EXT_ETHERNET_FIELDS_LEN + actual_octets;