File 278-fail-if-capture-has-a-packet-that-is-too-large.patch of Package tcpreplay

From: Fred Klassen <fklassen@appneta.com>
Date: Sun, 26 Feb 2017 20:45:59 -0800
Subject: * #278 fail if capture has a packet that is too large
Patch-mainline: v4.2.0-beta1
Git-commit: d689d14dbcd768c028eab2fb378d849e543dcfe9
References: CVE-2017-6429 bsc#1028234

* Update CHANGELOG

---
 src/tcpcapinfo.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/tcpcapinfo.c b/src/tcpcapinfo.c
index 775f1625b00f..96928820fe94 100644
--- a/src/tcpcapinfo.c
+++ b/src/tcpcapinfo.c
@@ -281,6 +281,15 @@ main(int argc, char *argv[])
                 caplen = pcap_ph.caplen;
             }
 
+            if (caplentoobig) {
+                printf("\n\nCapture file appears to be damaged or corrupt.\n"
+                        "Contains packet of size %u, bigger than snap length %u\n",
+                        caplen, pcap_fh.snaplen);
+
+                close(fd);
+                break;
+            }
+
             /* check to make sure timestamps don't go backwards */
             if (last_sec > 0 && last_usec > 0) {
                 if ((pcap_ph.ts.tv_sec == last_sec) ? 
@@ -306,7 +315,7 @@ main(int argc, char *argv[])
                 }
 
                 close(fd);
-                continue;
+                break;
             }
 
             /* print the frame checksum */
-- 
2.12.0

openSUSE Build Service is sponsored by