Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-4923

compress_tar incorrectly determines type

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0.RC1
    • Fix Version/s: 3.0.8-RC1
    • Component/s: Other
    • Labels:
      None
    • Environment:
      PHP Environment:
      Database:

      Description

      The class compress_tar in file includes/functions_compress.php tries to determine the exact type of the tarball like this:
      $this->isgz = (strpos($type, '.tar.gz') !== false || strpos($type, '.tgz') !== false) ? true : false;
      $this->isbz = (strpos($type, '.tar.bz2') !== false) ? true : false;

      Obviously, this can lead to problems on malformed filenames like foo.tgz.tar.bz2. The type would be determined as a gzip-compressed tarball, instead of a bzip-compressed one. It would be safer to match the type using a regular expression, including the end-of-string delimiter:
      $this->isgz = (preg_match('#.tar.gz$#i', $type) ? .....

      This doesn't affect Olympus itself, but could cause a problem if the class is used more widely.

        Activity

        Hide
        igorw Igor Wiedler [X] (Inactive) added a comment -

        I don't see any reason not to do this, the proposed implementation doesn't escape the '.' character properly though.

        Show
        igorw Igor Wiedler [X] (Inactive) added a comment - I don't see any reason not to do this, the proposed implementation doesn't escape the '.' character properly though.
        Hide
        hades79 hades79 added a comment -

        Yes, that's absolutely right:
        $this->isgz = (preg_match('#\.tar.gz$#i', $type) ? .....

        @evil<3: thanks for digging this one out, maybe somebody will fix it now that it's been sitting around for more than 2 years...

        Show
        hades79 hades79 added a comment - Yes, that's absolutely right: $this->isgz = (preg_match('#\.tar.gz$#i', $type) ? ..... @evil<3: thanks for digging this one out, maybe somebody will fix it now that it's been sitting around for more than 2 years...
        Show
        igorw Igor Wiedler [X] (Inactive) added a comment - Proposed fix: http://github.com/evil3/phpbb3/commits/bug/12531
        Hide
        naderman Nils Adermann added a comment -

        Merged into develop-olympus.

        Show
        naderman Nils Adermann added a comment - Merged into develop-olympus.

          People

          • Assignee:
            naderman Nils Adermann
            Reporter:
            hades79 hades79
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development