~ubuntu-branches/ubuntu/wily/squirrelmail/wily

« back to all changes in this revision

Viewing changes to plugins/mail_fetch/functions.php

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Wenning
  • Date: 2010-06-24 14:19:29 UTC
  • Revision ID: james.westby@ubuntu.com-20100624141929-cgioazl172gmzi91
Tags: 2:1.4.20-1ubuntu1
* SECURITY UPDATE: (LP: #598077)
* The Mail Fetch plugin allows remote authenticated users to bypass firewall
  restrictions and use SquirrelMail as a proxy to scan internal networks via
  a modified POP3 port number.
  - http://squirrelmail.org/security/issue/2010-06-21
  - CVE-2010-1637
  - Patch taken from upstream svn rev. 13951. Applied inline.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 */
27
27
$mail_fetch_allow_unsubscribed = false;
28
28
 
 
29
/**
 
30
  * Validate a requested POP3 port number
 
31
  *
 
32
  * Allowable port numbers are configured in config.php
 
33
  * (see config_example.php for an example and more
 
34
  * rules about how the list of allowable port numbers
 
35
  * can be specified)
 
36
  *
 
37
  * @param int $requested_port The port number given by the user
 
38
  *
 
39
  * @return string An error string is returned if the port
 
40
  *                number is not allowable, otherwise an
 
41
  *                empty string is returned.
 
42
  *
 
43
  */
 
44
function validate_mail_fetch_port_number($requested_port) {
 
45
    global $mail_fetch_allowable_ports;
 
46
    @include_once(SM_PATH . 'plugins/mail_fetch/config.php');
 
47
    if (empty($mail_fetch_allowable_ports))
 
48
        $mail_fetch_allowable_ports = array(110, 995);
 
49
 
 
50
    if (in_array('ALL', $mail_fetch_allowable_ports))
 
51
        return '';
 
52
 
 
53
    if (!in_array($requested_port, $mail_fetch_allowable_ports)) {
 
54
        sq_change_text_domain('mail_fetch');
 
55
        $error = _("Sorry, that port number is not allowed");
 
56
        sq_change_text_domain('squirrelmail');
 
57
        return $error;
 
58
    }
 
59
 
 
60
    return '';
 
61
}
 
62
 
 
63
/**
 
64
  * Validate a requested POP3 server address
 
65
  *
 
66
  * Blocked server addresses are configured in config.php
 
67
  * (see config_example.php for more details)
 
68
  *
 
69
  * @param int $requested_address The server address given by the user
 
70
  *
 
71
  * @return string An error string is returned if the server
 
72
  *                address is not allowable, otherwise an
 
73
  *                empty string is returned.
 
74
  *
 
75
  */
 
76
function validate_mail_fetch_server_address($requested_address) {
 
77
    global $mail_fetch_block_server_pattern;
 
78
    @include_once(SM_PATH . 'plugins/mail_fetch/config.php');
 
79
    if (empty($mail_fetch_block_server_pattern))
 
80
        $mail_fetch_block_server_pattern = '/(^10\.)|(^192\.)|(^127\.)|(^localhost)/';
 
81
 
 
82
    if ($mail_fetch_block_server_pattern == 'UNRESTRICTED')
 
83
        return '';
 
84
 
 
85
    if (preg_match($mail_fetch_block_server_pattern, $requested_address)) {
 
86
        sq_change_text_domain('mail_fetch');
 
87
        $error = _("Sorry, that server address is not allowed");
 
88
        sq_change_text_domain('squirrelmail');
 
89
        return $error;
 
90
    }
 
91
 
 
92
    return '';
 
93
}
 
94
 
29
95
function hex2bin( $data ) {
30
96
    /* Original code by josh@superfork.com */
31
97