enforce-maxpacket.patch 1.4 KB

123456789101112131415161718192021222324252627282930
  1. Subject: tcprewrite: Handle frames of 65535 octets size
  2. Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
  3. Date: Mon Jun 29 17:08:24 2015 +0200
  4. diff --git a/src/defines.h.in b/src/defines.h.in
  5. index 3a1bf1e..5468d14 100644
  6. --- a/src/defines.h.in
  7. +++ b/src/defines.h.in
  8. @@ -104,7 +104,7 @@ typedef struct tcpr_speed_s tcpr_speed_t;
  9. #define DEFAULT_MTU 1500 /* Max Transmission Unit of standard ethernet
  10. * don't forget *frames* are MTU + L2 header! */
  11. -#define MAXPACKET 65535 /* was 16436 linux loopback, but maybe something is bigger then
  12. +#define MAXPACKET 65549 /* was 16436 linux loopback, but maybe something is bigger then
  13. linux loopback */
  14. #define MAX_SNAPLEN 65535 /* tell libpcap to capture the entire packet */
  15. diff --git a/src/tcprewrite.c b/src/tcprewrite.c
  16. index 90a6f2e..9c32a5e 100644
  17. --- a/src/tcprewrite.c
  18. +++ b/src/tcprewrite.c
  19. @@ -253,6 +253,8 @@ rewrite_packets(tcpedit_t *tcpedit, pcap_t *pin, pcap_dumper_t *pout)
  20. packetnum++;
  21. dbgx(2, "packet " COUNTER_SPEC " caplen %d", packetnum, pkthdr.caplen);
  22. + if (pkthdr.caplen > MAXPACKET)
  23. + errx(-1, "Frame too big, caplen %d exceeds %d", pkthdr.caplen, MAXPACKET);
  24. /*
  25. * copy over the packet so we can pad it out if necessary and
  26. * because pcap_next() returns a const ptr