Note some cases where we don't need to check the packet length.
These file formats have 16-bit packet lengths, so, even with some extra metadata added, the packet data length will never be bigger than WTAP_MAX_PACKET_SIZE. (No, we won't ever reduce WTAP_MAX_PACKET_SIZE.) Change-Id: I9e1b1d90971f91cc6e5d66d0aa93841445b2bc22 Reviewed-on: https://code.wireshark.org/review/15186 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
44f72a90ea
commit
c34cf306ab
|
@ -244,6 +244,12 @@ camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
|||
|
||||
if (!find_next_pkt_dat_type_len(fh, &dat_trans_type, &dat_len, err, err_info))
|
||||
return FALSE;
|
||||
/*
|
||||
* The maximum value of length is 65535, which, even after
|
||||
* DVB_CI_PSEUDO_HDR_LEN is added to it, is less than
|
||||
* WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check
|
||||
* it.
|
||||
*/
|
||||
|
||||
ws_buffer_assure_space(buf, DVB_CI_PSEUDO_HDR_LEN+dat_len);
|
||||
p = ws_buffer_start_ptr(buf);
|
||||
|
|
|
@ -146,6 +146,11 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
|||
|
||||
if(!commview_read_header(&cv_hdr, fh, err, err_info))
|
||||
return FALSE;
|
||||
/*
|
||||
* The maximum value of cv_hdr.data_len is 65535, which is less
|
||||
* than WTAP_MAX_PACKET_SIZE will ever be, so we don't need to
|
||||
* check it.
|
||||
*/
|
||||
|
||||
switch(cv_hdr.flags & FLAGS_MEDIUM) {
|
||||
|
||||
|
|
|
@ -179,6 +179,11 @@ csids_read_packet(FILE_T fh, csids_t *csids, struct wtap_pkthdr *phdr,
|
|||
return FALSE;
|
||||
hdr.seconds = pntoh32(&hdr.seconds);
|
||||
hdr.caplen = pntoh16(&hdr.caplen);
|
||||
/*
|
||||
* The maximum value of hdr.caplen is 65535, which is less than
|
||||
* WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check
|
||||
* it.
|
||||
*/
|
||||
|
||||
phdr->rec_type = REC_TYPE_PACKET;
|
||||
phdr->presence_flags = WTAP_HAS_TS;
|
||||
|
|
|
@ -157,6 +157,11 @@ ipfix_read_message(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, g
|
|||
|
||||
if (!ipfix_read_message_header(&msg_hdr, fh, err, err_info))
|
||||
return FALSE;
|
||||
/*
|
||||
* The maximum value of msg_hdr.message_length is 65535, which is
|
||||
* less than WTAP_MAX_PACKET_SIZE will ever be, so we don't need
|
||||
* to check it.
|
||||
*/
|
||||
|
||||
phdr->rec_type = REC_TYPE_PACKET;
|
||||
phdr->presence_flags = WTAP_HAS_TS;
|
||||
|
|
|
@ -482,6 +482,11 @@ static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh,
|
|||
|
||||
true_size = pletoh16(&descriptor[4]);
|
||||
packet_size = pletoh16(&descriptor[6]);
|
||||
/*
|
||||
* The maximum value of packet_size is 65535, which is less than
|
||||
* WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check
|
||||
* it.
|
||||
*/
|
||||
|
||||
/*
|
||||
* OK, is the frame data size greater than than what's left of the
|
||||
|
|
|
@ -186,6 +186,12 @@ static gboolean logcat_read_packet(struct logcat_phdr *logcat, FILE_T fh,
|
|||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
/*
|
||||
* The maximum value of payload_length is 65535, which, even after
|
||||
* the size of the logger entry structure is added to it, is less
|
||||
* than WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check
|
||||
* it.
|
||||
*/
|
||||
|
||||
ws_buffer_assure_space(buf, packet_size);
|
||||
pd = ws_buffer_start_ptr(buf);
|
||||
|
|
|
@ -938,6 +938,9 @@ static gboolean nstrace_set_start_time(wtap *wth)
|
|||
|
||||
/*
|
||||
** Netscaler trace format read routines.
|
||||
**
|
||||
** The maximum value of the record data size is 65535, which is less than
|
||||
** WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check it.
|
||||
*/
|
||||
#define TIMEDEFV10(phdr,fp,type) \
|
||||
do {\
|
||||
|
@ -1075,6 +1078,10 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *
|
|||
#define TIMEDEFV25(phdr,fp,type) TIMEDEFV24(phdr,fp,type)
|
||||
#define TIMEDEFV26(phdr,fp,type) TIMEDEFV24(phdr,fp,type)
|
||||
|
||||
/*
|
||||
** The maximum value of the record data size is 65535, which is less than
|
||||
** WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check it.
|
||||
*/
|
||||
#define PARTSIZEDEFV20(phdr,pp,ver) \
|
||||
do {\
|
||||
(phdr)->presence_flags |= WTAP_HAS_CAP_LEN;\
|
||||
|
@ -1244,6 +1251,10 @@ static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *
|
|||
|
||||
#define TIMEDEFV35 TIMEDEFV30
|
||||
|
||||
/*
|
||||
** The maximum value of the record data size is 65535, which is less than
|
||||
** WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check it.
|
||||
*/
|
||||
#define FULLSIZEDEFV30(phdr,fp,ver)\
|
||||
do {\
|
||||
(phdr)->presence_flags |= WTAP_HAS_CAP_LEN;\
|
||||
|
@ -1665,6 +1676,8 @@ static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
|
|||
|
||||
/*
|
||||
** Get the record length.
|
||||
** The maximum value of the record data size is 65535, which is less
|
||||
** than WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check it.
|
||||
*/
|
||||
record_length = nspr_getv20recordsize(&hdr);
|
||||
|
||||
|
|
|
@ -471,6 +471,11 @@ process_packet_header(wtap *wth, packet_entry_header *packet_header,
|
|||
phdr->len = packet_header->network_size - 4;
|
||||
phdr->caplen = MIN(packet_header->captured_size, phdr->len);
|
||||
}
|
||||
/*
|
||||
* The maximum value of packet_header->captured_size is 65535, which
|
||||
* is less than WTAP_MAX_PACKET_SIZE will ever be, so we don't need
|
||||
* to check it.
|
||||
*/
|
||||
|
||||
/* set the wiretap timestamp, assuming for the moment that Observer encoded it in GMT */
|
||||
phdr->ts.secs = (time_t) ((packet_header->nano_seconds_since_2000 / 1000000000) + ansi_to_observer_epoch_offset);
|
||||
|
|
|
@ -1298,6 +1298,11 @@ ngsniffer_process_record(wtap *wth, gboolean is_random, guint *padding,
|
|||
*err_info = g_strdup("ngsniffer: Record length is less than packet size");
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
* The maximum value of length is 65535, which is less than
|
||||
* WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check
|
||||
* it.
|
||||
*/
|
||||
|
||||
if (padding != NULL) {
|
||||
/*
|
||||
|
|
|
@ -434,6 +434,11 @@ static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh,
|
|||
if (0 == sliceLength) {
|
||||
sliceLength = length;
|
||||
}
|
||||
/*
|
||||
* The maximum value of sliceLength and length are 65535, which
|
||||
* are less than WTAP_MAX_PACKET_SIZE will ever be, so we don't
|
||||
* need to check them.
|
||||
*/
|
||||
|
||||
/* fill in packet header values */
|
||||
phdr->rec_type = REC_TYPE_PACKET;
|
||||
|
@ -613,6 +618,11 @@ static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh,
|
|||
if (0 == sliceLength) {
|
||||
sliceLength = length;
|
||||
}
|
||||
/*
|
||||
* The maximum value of sliceLength and length are 65535, which
|
||||
* are less than WTAP_MAX_PACKET_SIZE will ever be, so we don't
|
||||
* need to check them.
|
||||
*/
|
||||
|
||||
/* fill in packet header values */
|
||||
phdr->rec_type = REC_TYPE_PACKET;
|
||||
|
|
|
@ -306,6 +306,11 @@ radcom_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
|||
}
|
||||
length = pletoh16(&hdr.length);
|
||||
real_length = pletoh16(&hdr.real_length);
|
||||
/*
|
||||
* The maximum value of length is 65535, which is less than
|
||||
* WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check
|
||||
* it.
|
||||
*/
|
||||
|
||||
phdr->rec_type = REC_TYPE_PACKET;
|
||||
phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
||||
|
|
Loading…
Reference in New Issue