You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.4 KiB

  1. From 9c84b7426660c09c18cc349f6d70b5f8168b5680 Mon Sep 17 00:00:00 2001
  2. From: Daniel Axtens <dja@axtens.net>
  3. Date: Tue, 4 Dec 2018 16:33:42 +1100
  4. Subject: [PATCH] warc: consume data once read
  5. The warc decoder only used read ahead, it wouldn't actually consume
  6. data that had previously been printed. This means that if you specify
  7. an invalid content length, it will just reprint the same data over
  8. and over and over again until it hits the desired length.
  9. This means that a WARC resource with e.g.
  10. Content-Length: 666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666665
  11. but only a few hundred bytes of data, causes a quasi-infinite loop.
  12. Consume data in subsequent calls to _warc_read.
  13. Found with an AFL + afl-rb + qsym setup.
  14. ---
  15. libarchive/archive_read_support_format_warc.c | 5 +++++
  16. 1 file changed, 5 insertions(+)
  17. diff --git a/libarchive/archive_read_support_format_warc.c b/libarchive/archive_read_support_format_warc.c
  18. index e8753853f..e8fc8428b 100644
  19. --- a/libarchive/archive_read_support_format_warc.c
  20. +++ b/libarchive/archive_read_support_format_warc.c
  21. @@ -386,6 +386,11 @@ _warc_read(struct archive_read *a, const void **buf, size_t *bsz, int64_t *off)
  22. return (ARCHIVE_EOF);
  23. }
  24. + if (w->unconsumed) {
  25. + __archive_read_consume(a, w->unconsumed);
  26. + w->unconsumed = 0U;
  27. + }
  28. +
  29. rab = __archive_read_ahead(a, 1U, &nrd);
  30. if (nrd < 0) {
  31. *bsz = 0U;