fix-crash-on-huge-prefix-lists.patch 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. Description: Handle prefix lists with more than MAX_PREFIXES prefixes gracefully
  2. Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
  3. Bug: https://bitbucket.org/ripencc/bgpdump/issue/2/
  4. Bug: https://bitbucket.org/ripencc/bgpdump/issue/10/
  5. Bug: https://bitbucket.org/ripencc/bgpdump/issue/13/
  6. Bug: https://bitbucket.org/ripencc/bgpdump/issue/17/
  7. Bug: https://bitbucket.org/ripencc/bgpdump/issue/18/
  8. Last-Update: 2016-07-13
  9. --- a/bgpdump_lib.c
  10. +++ b/bgpdump_lib.c
  11. @@ -1589,11 +1589,16 @@
  12. break;
  13. }
  14. - struct prefix *prefix = prefixes + count;
  15. + struct prefix *prefix;
  16. - if(count++ > MAX_PREFIXES)
  17. - continue;
  18. -
  19. + if(count < MAX_PREFIXES) {
  20. + prefix = prefixes + count;
  21. + } else {
  22. + /* read and discard */
  23. + static struct prefix void_prefix;
  24. + prefix = &void_prefix;
  25. + }
  26. + count++;
  27. *prefix = (struct prefix) { .len = p_len, .path_id = path_id };
  28. mstream_get(s, &prefix->address, p_bytes);
  29. }