summaryrefslogtreecommitdiff
path: root/wiretap/snoop.c
diff options
context:
space:
mode:
Diffstat (limited to 'wiretap/snoop.c')
-rw-r--r--wiretap/snoop.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/wiretap/snoop.c b/wiretap/snoop.c
index fb9253706b..985cfe9f9e 100644
--- a/wiretap/snoop.c
+++ b/wiretap/snoop.c
@@ -887,10 +887,17 @@ static gboolean snoop_dump(wtap_dumper *wdh,
/* Record length = header length plus data length... */
reclen = (int)sizeof rec_hdr + phdr->caplen + atm_hdrsize;
+
/* ... plus enough bytes to pad it to a 4-byte boundary. */
padlen = ((reclen + 3) & ~3) - reclen;
reclen += padlen;
+ /* Don't write anything we're not willing to read. */
+ if (phdr->caplen + atm_hdrsize > WTAP_MAX_PACKET_SIZE) {
+ *err = WTAP_ERR_PACKET_TOO_LARGE;
+ return FALSE;
+ }
+
rec_hdr.orig_len = g_htonl(phdr->len + atm_hdrsize);
rec_hdr.incl_len = g_htonl(phdr->caplen + atm_hdrsize);
rec_hdr.rec_len = g_htonl(reclen);