catch-caplen-exceed.patch 804 B

12345678910111213141516171819202122
  1. Description: Catch frames with a capture length bigger than the buffer
  2. Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
  3. Bug: https://github.com/appneta/tcpreplay/issues/405
  4. Last-Update: 2017-06-12
  5. --- a/src/tcpcapinfo.c
  6. +++ b/src/tcpcapinfo.c
  7. @@ -306,6 +306,14 @@
  8. last_usec = pcap_ph.ts.tv_usec;
  9. }
  10. + if (caplen > 10000) {
  11. + printf("\n\nCapture file appears to be damaged or corrupt.\n"
  12. + "Contains packet of size %u, bigger than buffer length %u\n",
  13. + caplen, 10000);
  14. + close(fd);
  15. + break;
  16. + }
  17. +
  18. /* read the frame */
  19. maxread = min((size_t)caplen, sizeof(buf));
  20. if ((ret = read(fd, &buf, maxread)) != maxread) {