aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wiretap/stanag4607.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/wiretap/stanag4607.c b/wiretap/stanag4607.c
index 1845cc0ab5..9aa3105ba3 100644
--- a/wiretap/stanag4607.c
+++ b/wiretap/stanag4607.c
@@ -73,6 +73,16 @@ static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *p
/* The next 4 bytes are the packet length */
packet_size = pntoh32(&stanag_pkt_hdr[2]);
+ if (packet_size > WTAP_MAX_PACKET_SIZE) {
+ /*
+ * Probably a corrupt capture file; don't blow up trying
+ * to allocate space for an immensely-large packet.
+ */
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup_printf("stanag4607: File has %" G_GUINT32_FORMAT "d-byte packet, "
+ "bigger than maximum of %u", packet_size, WTAP_MAX_PACKET_SIZE);
+ return FALSE;
+ }
phdr->caplen = packet_size;
phdr->len = packet_size;