~ubuntu-branches/ubuntu/quantal/awstats/quantal

« back to all changes in this revision

Viewing changes to .pc/1004_perl_version.patch/wwwroot/cgi-bin/awstats.pl

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard, Sergey B Kirpichev, Jonas Smedegaard
  • Date: 2010-12-24 00:05:07 UTC
  • Revision ID: james.westby@ubuntu.com-20101224000507-5tgshwgf2wwnzqv7
Tags: 6.9.5~dfsg-5
[ Sergey B Kirpichev ]
* Bump up Standards-Version to 3.9.1.
* Remove examples/staticpages.sh.
* Take sucurity fixes from upstream CVS:
  - CVE-2010-4369: patch 0009 (closes directory traversal vulnerability via
    crafted LoadPlugin directory).
  - CVE-2010-4367(and CVE-2010-4368): update patch 1002 (sanitize configdir,
    disable overwriting of configdir parameter in cgi mode).
  Closes: bug#606263.

[ Jonas Smedegaard ]
* Unfuzz patches.
* Ease building with git-buildpackage:
  + Add dpkg-source local-options.
  + Suppress .pc dir.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1716
1716
        # Other possible directories :                          "/usr/local/etc/awstats", "/etc"
1717
1717
        # FHS standard, Suse package :                          "/etc/opt/awstats"
1718
1718
        my $configdir         = shift;
1719
 
        my @PossibleConfigDir = ();
1720
 
 
1721
 
        if ($configdir) {
1722
 
                # If from CGI, overwriting of configdir is only possible if AWSTATS_ENABLE_CONFIG_DIR defined
1723
 
                if ($ENV{'GATEWAY_INTERFACE'} && ! $ENV{"AWSTATS_ENABLE_CONFIG_DIR"}) {
1724
 
                        error("Sorry, to allow overwriting of configdir parameter from an AWStats CGI usage, environment variable AWSTATS_ENABLE_CONFIG_DIR must be set to 1");
1725
 
                }
1726
 
                else {
1727
 
                        @PossibleConfigDir = ("$configdir");
1728
 
                }
1729
 
        }
1730
 
        else {
1731
 
                @PossibleConfigDir = (
1732
 
                        "$DIR",                   "/etc/awstats",
 
1719
        my @PossibleConfigDir = (
 
1720
                        "$DIR",
 
1721
                        "/etc/awstats",
1733
1722
                        "/usr/local/etc/awstats", "/etc",
1734
1723
                        "/etc/opt/awstats"
1735
1724
                );
 
1725
 
 
1726
        if ($configdir) {
 
1727
                # Check if configdir is outside default values.
 
1728
                my $outsidedefaultvalue=1;
 
1729
                foreach (@PossibleConfigDir) {
 
1730
                        if ($_ eq $configdir) { $outsidedefaultvalue=0; last; }
 
1731
                }
 
1732
 
 
1733
                # If from CGI, overwriting of configdir with a value that differs from a default value
 
1734
                # is only possible if AWSTATS_ENABLE_CONFIG_DIR defined
 
1735
                if ($ENV{'GATEWAY_INTERFACE'} && $outsidedefaultvalue && ! $ENV{"AWSTATS_ENABLE_CONFIG_DIR"})
 
1736
                {
 
1737
                        error("Sorry, to allow overwriting of configdir parameter, from an AWStats CGI page, with a non default value, environment variable AWSTATS_ENABLE_CONFIG_DIR must be set to 1. For example, by adding the line 'SetEnv AWSTATS_ENABLE_CONFIG_DIR 1' in your Apache config file or into a .htaccess file.");
 
1738
                }
 
1739
 
 
1740
                @PossibleConfigDir = ("$configdir");
1736
1741
        }
1737
1742
 
1738
1743
        # Open config file
1848
1853
                                );
1849
1854
                                next;
1850
1855
                        }
 
1856
                        local( *CONFIG_INCLUDE );
1851
1857
                        if ( open( CONFIG_INCLUDE, $includeFile ) ) {
1852
1858
                                &Parse_Config( *CONFIG_INCLUDE, $level + 1, $includeFile );
1853
1859
                                close(CONFIG_INCLUDE);
3053
3059
                  "";    # If split has only on part, pluginparam is not initialized
3054
3060
                $pluginfile =~ s/\.pm$//i;
3055
3061
                $pluginfile =~ /([^\/\\]+)$/;
3056
 
                my $pluginname = $1;    # pluginname is pluginfile without any path
3057
 
                                        # Check if plugin is not disabled
 
3062
                $pluginfile = Sanitize($1);     # pluginfile is cleaned from any path for security reasons and from .pm
 
3063
                my $pluginname = $pluginfile;
3058
3064
                if ( $NoLoadPlugin{$pluginname} && $NoLoadPlugin{$pluginname} > 0 ) {
3059
3065
                        if ($Debug) {
3060
3066
                                debug(
7719
7725
        my $stringtoclean = shift;
7720
7726
        my $full = shift || 0;
7721
7727
        if ($full) {
7722
 
                $stringtoclean =~ s/[^\w]//g;
 
7728
                $stringtoclean =~ s/[^\w\d]//g;
7723
7729
        }
7724
7730
        else {
7725
 
                $stringtoclean =~ s/[^\w\-\\\/\.:\s]//g;
 
7731
                $stringtoclean =~ s/[^\w\d\-\\\/\.:\s]//g;
7726
7732
        }
7727
7733
        return $stringtoclean;
7728
7734
}
9540
9546
        }
9541
9547
        if ( $QueryString =~ /configdir=([^&]+)/i ) {
9542
9548
                $DirConfig = &Sanitize("$1");
 
9549
                $DirConfig =~ s/\\{2,}/\\/g;    # This is to clean Remote URL
 
9550
                $DirConfig =~ s/\/{2,}/\//g;    # This is to clean Remote URL
9543
9551
        }
9544
9552
 
9545
9553
        # All filters
9625
9633
        }
9626
9634
        if ( $QueryString =~ /configdir=([^&]+)/i ) {
9627
9635
                $DirConfig = &Sanitize("$1");
 
9636
                $DirConfig =~ s/\\{2,}/\\/g;    # This is to clean Remote URL
 
9637
                $DirConfig =~ s/\/{2,}/\//g;    # This is to clean Remote URL
9628
9638
        }
9629
9639
 
9630
9640
        # All filters