Author: delphij
Date: Tue Feb 23 07:04:54 2016
New Revision: 295913
URL: https://svnweb.freebsd.org/changeset/base/295913

Log:
  Apply upstream commit 6e06b1c8 (partial, by kientzle):
  
  Fix a potential crash issue discovered by Alexander Cherepanov:
  It seems bsdtar automatically handles stacked compression. This is a
  nice feature but it could be problematic when it's completely
  unlimited.  Most clearly it's illustrated with quines:
  
  $ curl -sRO http://www.maximumcompression.com/selfgz.gz
  $ (ulimit -v 10000000 && bsdtar -tvf selfgz.gz)
  bsdtar: Error opening archive: Can't allocate data for gzip decompression
  
  Without ulimit, bsdtar will eat all available memory. This could also
  be a problem for other applications using libarchive.

Modified:
  vendor/libarchive/dist/libarchive/archive_read.c

Modified: vendor/libarchive/dist/libarchive/archive_read.c
==============================================================================
--- vendor/libarchive/dist/libarchive/archive_read.c    Tue Feb 23 06:29:57 
2016        (r295912)
+++ vendor/libarchive/dist/libarchive/archive_read.c    Tue Feb 23 07:04:54 
2016        (r295913)
@@ -544,13 +544,13 @@ archive_read_open1(struct archive *_a)
 static int
 choose_filters(struct archive_read *a)
 {
-       int number_bidders, i, bid, best_bid;
+       int number_bidders, i, bid, best_bid, n;
        struct archive_read_filter_bidder *bidder, *best_bidder;
        struct archive_read_filter *filter;
        ssize_t avail;
        int r;
 
-       for (;;) {
+       for (n = 0; n < 25; ++n) {
                number_bidders = sizeof(a->bidders) / sizeof(a->bidders[0]);
 
                best_bid = 0;
@@ -596,6 +596,9 @@ choose_filters(struct archive_read *a)
                        return (ARCHIVE_FATAL);
                }
        }
+       archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+           "Input requires too many filters for decoding");
+       return (ARCHIVE_FATAL);
 }
 
 /*
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to