Browse Source

Handle frames with a capture length bigger than the buffer

Christoph Biedl 6 years ago
parent
commit
bc006c6777
2 changed files with 23 additions and 0 deletions
  1. 22 0
      debian/patches/catch-caplen-exceed.patch
  2. 1 0
      debian/patches/series

+ 22 - 0
debian/patches/catch-caplen-exceed.patch

@@ -0,0 +1,22 @@
+Description: Catch frames with a capture length bigger than the buffer
+Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
+Bug: https://github.com/appneta/tcpreplay/issues/405
+Last-Update: 2017-06-12
+
+--- a/src/tcpcapinfo.c
++++ b/src/tcpcapinfo.c
+@@ -306,6 +306,14 @@
+                 last_usec = pcap_ph.ts.tv_usec;
+             }
+ 
++            if (caplen > 10000) {
++                printf("\n\nCapture file appears to be damaged or corrupt.\n"
++                        "Contains packet of size %u, bigger than buffer length %u\n",
++                        caplen, 10000);
++                close(fd);
++                break;
++            }
++
+             /* read the frame */
+             if ((ret = read(fd, &buf, caplen)) != caplen) {
+                 if (ret < 0) {

+ 1 - 0
debian/patches/series

@@ -1 +1,2 @@
 disable-tcpreplay-test.patch
+catch-caplen-exceed.patch