fix-time-t-expansion.patch 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. Description: Fix time_t expansion on big-endian archs where sizeof(time_t) > 4
  2. Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
  3. Bug: https://bitbucket.org/ripencc/bgpdump/issues/38/
  4. Bug-Debian: https://bugs.debian.org/832468
  5. Last-Update: 2016-08-04
  6. On these archs the present code places the time_t data in the wrong
  7. 32 bits of time_t. Additionally, broken libc implementations do not
  8. mask the result of ntohl to the size of 32 bit, resulting in a huge
  9. time_t value that gmtime cannot handle, which eventually leads to a
  10. segfault.
  11. --- a/bgpdump_lib.c
  12. +++ b/bgpdump_lib.c
  13. @@ -138,10 +138,11 @@
  14. u_char *buffer;
  15. int ok=0;
  16. u_int32_t bytes_read;
  17. + u_int32_t t;
  18. this_entry = malloc_check(sizeof(BGPDUMP_ENTRY));
  19. - bytes_read = cfr_read_n(dump->f, &(this_entry->time), 4);
  20. + bytes_read = cfr_read_n(dump->f, &t, 4);
  21. bytes_read += cfr_read_n(dump->f, &(this_entry->type), 2);
  22. bytes_read += cfr_read_n(dump->f, &(this_entry->subtype), 2);
  23. bytes_read += cfr_read_n(dump->f, &(this_entry->length), 4);
  24. @@ -150,7 +151,7 @@
  25. /* Intel byte ordering stuff ... */
  26. this_entry->type = ntohs(this_entry->type);
  27. this_entry->subtype = ntohs(this_entry->subtype);
  28. - this_entry->time = ntohl(this_entry->time);
  29. + this_entry->time = (time_t) ntohl (t);
  30. this_entry->length = ntohl(this_entry->length);
  31. /* If Extended Header format, then reading the miscroseconds attribute */