Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

More robust handling of missing/unknown compression types

  • Loading branch information...
commit dc70ad36c55c1fe391ff1e215b85c8d067dcbd8d 1 parent 9ceffd9
Michiel Rook mrook authored

Showing 1 changed file with 11 additions and 5 deletions. Show diff stats Hide diff stats

  1. +11 5 Archive/Tar.php
16 Archive/Tar.php
@@ -680,9 +680,11 @@ function _openWrite()
680 680 $this->_file = @bzopen($this->_tarname, "w");
681 681 else if ($this->_compress_type == 'none')
682 682 $this->_file = @fopen($this->_tarname, "wb");
683   - else
  683 + else {
684 684 $this->_error('Unknown or missing compression type ('
685 685 .$this->_compress_type.')');
  686 + return false;
  687 + }
686 688
687 689 if ($this->_file == 0) {
688 690 $this->_error('Unable to open in write mode \''
@@ -727,15 +729,17 @@ function _openRead()
727 729 // ----- File to open if the normal Tar file
728 730 $v_filename = $this->_tarname;
729 731
730   - if ($this->_compress_type == 'gz')
  732 + if ($this->_compress_type == 'gz' && function_exists('gzopen'))
731 733 $this->_file = @gzopen($v_filename, "rb");
732   - else if ($this->_compress_type == 'bz2')
  734 + else if ($this->_compress_type == 'bz2' && function_exists('bzopen'))
733 735 $this->_file = @bzopen($v_filename, "r");
734 736 else if ($this->_compress_type == 'none')
735 737 $this->_file = @fopen($v_filename, "rb");
736   - else
  738 + else {
737 739 $this->_error('Unknown or missing compression type ('
738 740 .$this->_compress_type.')');
  741 + return false;
  742 + }
739 743
740 744 if ($this->_file == 0) {
741 745 $this->_error('Unable to open in read mode \''.$v_filename.'\'');
@@ -757,9 +761,11 @@ function _openReadWrite()
757 761 return false;
758 762 } else if ($this->_compress_type == 'none')
759 763 $this->_file = @fopen($this->_tarname, "r+b");
760   - else
  764 + else {
761 765 $this->_error('Unknown or missing compression type ('
762 766 .$this->_compress_type.')');
  767 + return false;
  768 + }
763 769
764 770 if ($this->_file == 0) {
765 771 $this->_error('Unable to open in read/write mode \''

0 comments on commit dc70ad3

Please sign in to comment.
Something went wrong with that request. Please try again.