cherry-pick.v4.3.1-12-gdae97cba.bugs-538-add-check-for-packet-length-in-do-checksum.patch 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. Subject: Bugs #538 add check for packet length in do_checksum()
  2. ID: CVE-2019-8381
  3. Origin: v4.3.1-12-gdae97cba <https://github.com/appneta/tcpreplay/commit/v4.3.1-12-gdae97cba>
  4. Upstream-Author: Fred Klassen <fklassen@appneta.com>
  5. Date: Tue Mar 12 13:29:10 2019 -0700
  6. Bug-Debian: https://bugs.debian.org/922622
  7. --- a/src/tcpedit/checksum.c
  8. +++ b/src/tcpedit/checksum.c
  9. @@ -41,6 +41,7 @@
  10. udp_hdr_t *udp;
  11. icmpv4_hdr_t *icmp;
  12. icmpv6_hdr_t *icmp6;
  13. + u_char *layer;
  14. int ip_hl;
  15. int sum;
  16. @@ -62,7 +63,13 @@
  17. proto = get_ipv6_l4proto(ipv6, len);
  18. dbgx(3, "layer4 proto is 0x%hx", (uint16_t)proto);
  19. - ip_hl = (u_char*)get_layer4_v6(ipv6, len) - (u_char*)data;
  20. + layer = (u_char*)get_layer4_v6(ipv6, len);
  21. + if (!layer) {
  22. + tcpedit_setwarn(tcpedit, "%s", "Packet to short for checksum");
  23. + return TCPEDIT_WARN;
  24. + }
  25. +
  26. + ip_hl = layer - (u_char*)data;
  27. dbgx(3, "ip_hl proto is 0x%d", ip_hl);
  28. len -= (ip_hl - TCPR_IPV6_H);