From bc62c096d058c6db3ea45fcb8f0d041d4cb9580d Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 29 Apr 2016 19:10:01 -0700 Subject: [PATCH] Check for packets bigger than WTAP_MAX_PACKET_SIZE. Change-Id: Ia932f3e5aeaca7a566ea9f00ce1dca1a2071a1a4 Reviewed-on: https://code.wireshark.org/review/15187 Reviewed-by: Guy Harris --- wiretap/vms.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/wiretap/vms.c b/wiretap/vms.c index ebcfefb78c..2133c7802d 100644 --- a/wiretap/vms.c +++ b/wiretap/vms.c @@ -390,6 +390,17 @@ parse_vms_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gch break; } } while (! isdumpline(line)); + if (pkt_len > 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 = WTAP_ERR_BAD_FILE; + *err_info = g_strdup_printf("vms: File has %u-byte packet, bigger than maximum of %u", + pkt_len, WTAP_MAX_PACKET_SIZE); + return FALSE; + } p = strstr(months, mon); if (p)