From 4e7f4881d2cf6fe69de0661c2441e82dd525e59e Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 12 Jun 2018 11:23:32 -0700 Subject: [PATCH] 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 --- randpkt_core/randpkt_core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/randpkt_core/randpkt_core.c b/randpkt_core/randpkt_core.c index 628b941c23..b156fb9b67 100644 --- a/randpkt_core/randpkt_core.c +++ b/randpkt_core/randpkt_core.c @@ -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;