Don't let randpkt write packets libwiretap can't read.

Wiretap imposes an arbitrary limit on the maximum packet size, to
prevent it from trying to allocate a huge packet buffer and possibly
running out of address space on ILP32 platforms or just eating too much
backing store on LP64/LLP64 platforms.  Don't write packets with a
length greater than that limit.

Bug: 14107
Change-Id: Iba4fe3b008b044215647ba3f838ae7b3ac66c585
Reviewed-on: https://code.wireshark.org/review/28232
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2018-06-12 11:23:32 -07:00
parent a03eacc7aa
commit 4e7f4881d2
1 changed files with 7 additions and 0 deletions

View File

@ -593,6 +593,13 @@ void randpkt_loop(randpkt_example* example, guint64 produce_count)
}
len_this_pkt = example->sample_length + len_random;
if (len_this_pkt > WTAP_MAX_PACKET_SIZE_STANDARD) {
/*
* Wiretap will fail when trying to read packets
* bigger than WTAP_MAX_PACKET_SIZE_STANDARD.
*/
len_this_pkt = WTAP_MAX_PACKET_SIZE_STANDARD;
}
rec->rec_header.packet_header.caplen = len_this_pkt;
rec->rec_header.packet_header.len = len_this_pkt;