summaryrefslogtreecommitdiff
path: root/wiretap/nettl.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2011-12-13 02:42:42 +0000
committerGuy Harris <guy@alum.mit.edu>2011-12-13 02:42:42 +0000
commitc3da1f23d3793b4eb8ddf23f75a29d124c34b085 (patch)
tree98e800e5537d856b756e932ef7d66fa9da1e9afc /wiretap/nettl.c
parentdd92029afa511018f80b3bf28eca30ff9f8ee967 (diff)
downloadwireshark-c3da1f23d3793b4eb8ddf23f75a29d124c34b085.tar.gz
Add missing checks for a too-large packet, so we don't blow up trying to
allocate a huge buffer. svn path=/trunk/; revision=40170
Diffstat (limited to 'wiretap/nettl.c')
-rw-r--r--wiretap/nettl.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/wiretap/nettl.c b/wiretap/nettl.c
index fe6217915e..e265b45da9 100644
--- a/wiretap/nettl.c
+++ b/wiretap/nettl.c
@@ -318,6 +318,17 @@ static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
}
wth->data_offset += ret;
+ if (wth->phdr.caplen > 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_RECORD;
+ *err_info = g_strdup_printf("nettl: File has %u-byte packet, bigger than maximum of %u",
+ wth->phdr.caplen, WTAP_MAX_PACKET_SIZE);
+ return FALSE;
+ }
+
/*
* If the per-file encapsulation isn't known, set it to this
* packet's encapsulation.