Changeset 218

Show
Ignore:
Timestamp:
10/19/07 23:26:25 (15 months ago)
Author:
jonas
Message:
 
Location:
trunk
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r217 r218  
    33        o Fixed: recipient classes VIEW 
    44        o Improved: display mailbox size with units 
     5        o Improved: fist step to better inputchecks for XSS protection 
     6          Thanks to Sven Tantau (http://beastiebytes.com) 
    57CpVES 0.10 2007-10-11 - Jonas Genannt - <jonas.genannt@brachium-system.net> 
    68        o Improved: sa_learn.pl no longer debug output 
  • trunk/includes/func.inc.php

    r217 r218  
    5050} 
    5151 
     52function domain_valid($domain) { 
     53        if (preg_match("/^([0-9a-zA-Z\._\-]+)$/", $domain)) { 
     54                return true; 
     55        } 
     56        return false; 
     57} 
     58 
     59function clean_input($string) { 
     60        if (get_magic_quotes_gpc()) { 
     61                $string=stripslashes($string); 
     62        } 
     63        $string=strip_tags($string); 
     64        return $string; 
     65         
     66} 
     67 
    5268function get_all_langs() { 
    5369$table_lang = array(); 
     
    545561function email_valid($mail) 
    546562{ 
    547         if (ereg("^([a-zA-Z0-9._-]+)$", $mail)) 
     563        if (ereg("^([a-zA-Z0-9._\-]+)$", $mail)) 
    548564        { 
    549565                return true; 
     
    840856                $msg=stripslashes($msg); 
    841857        } 
     858        $esubject=clean_input($esubject); 
     859        $msg=clean_input($msg); 
    842860        if ($result->numRows()==1)  
    843861        { 
  • trunk/includes/sites/domain_add.php

    r165 r218  
    2727                        $smarty->assign('if_error_domain_exits', 'y'); 
    2828                        $smarty->assign('dnsname', $_POST['dnsname']); 
     29                } 
     30                elseif(!domain_valid($_POST['dnsname'])) { 
     31                        $smarty->assign('error_msg','y'); 
     32                        $smarty->assign('if_error_domain_wrong', 'y'); 
    2933                } 
    3034                else 
     
    6771                                $db->escapeSimple($max_email), 
    6872                                $db->escapeSimple($max_forward), 
    69                                 $db->escapeSimple(substr($_POST['dnote'],0,30)), 
     73                                $db->escapeSimple(clean_input(substr($_POST['dnote'],0,30)) ), 
    7074                                $db->escapeSimple($_POST['p_spamassassin']), 
    7175                                $db->escapeSimple($bogofilter), 
  • trunk/includes/sites/domain_view.php

    r217 r218  
    147147        if (isset($_POST['dnote'])) { 
    148148                $sql=sprintf("UPDATE domains SET dnote='%s' WHERE id='%d'", 
    149                         $db->escapeSimple($_POST['dnote']), 
     149                        $db->escapeSimple(clean_input(substr($_POST['dnote'],0,30))), 
    150150                        $db->escapeSimple($_GET['did'])); 
    151151                $db->query($sql); 
  • trunk/includes/sites/email_add.php

    r142 r218  
    131131                                $db->escapeSimple($_GET['did']), 
    132132                                $db->escapeSimple($cleartext), 
    133                                 $db->escapeSimple($_POST['full_name']), 
     133                                $db->escapeSimple(clean_input(trim($_POST['full_name']))), 
    134134                                $db->escapeSimple($imap), 
    135135                                $db->escapeSimple($pop3), 
  • trunk/includes/sites/email_view.php

    r208 r218  
    9898                        $smarty->assign('if_wrong_sa_subjecttag','y'); 
    9999                } 
     100                elseif (!preg_match("/^([0-9A-Za-z*\s\+\.\-_\]\[]+)$/",$_POST['rewrite_subject_header'])) { 
     101                        $smarty->assign('error_msg', 'y'); 
     102                        $smarty->assign('if_illegal_sa_subjecttag','y'); 
     103                } 
    100104                else 
    101105                { 
     
    106110                        elseif ($_POST['rewrite_subject']==1) 
    107111                        { 
    108                                 $rewrite_subject=$_POST['rewrite_subject_header']; 
     112                                $rewrite_subject=clean_input(trim($_POST['rewrite_subject_header'])); 
    109113                         
    110114                        } 
     
    587591                                $sql=sprintf("UPDATE users SET passwd='%s', full_name='%s',p_imap='%d', p_pop3='%d',p_webmail='%d',     cpasswd='%s', p_forwarding='%s',p_spamassassin='%s',p_mailarchive='%d',p_bogofilter='%d',p_spam_del='%d',p_sa_learn='%d',p_fetchmail='%d',p_webinterface='%d',p_autores_xheader='%d',p_check_polw='%d',p_check_grey='%d',p_spam_fwd='%d' WHERE id='%d' ", 
    588592                                        $db->escapeSimple($cleartext), 
    589                                         $db->escapeSimple($_POST['full_name']), 
     593                                        $db->escapeSimple(clean_input(trim($_POST['full_name']))), 
    590594                                        $db->escapeSimple($imap), 
    591595                                        $db->escapeSimple($pop3), 
  • trunk/includes/sites/user_spam.php

    r207 r218  
    5151                        $smarty->assign('if_wrong_sa_subjecttag','y'); 
    5252                } 
     53                elseif (!preg_match("/^([0-9A-Za-z*\s\+\.\-_\]\[]+)$/",$_POST['rewrite_subject_header'])) { 
     54                        $smarty->assign('error_msg', 'y'); 
     55                        $smarty->assign('if_illegal_sa_subjecttag','y'); 
     56                } 
    5357                else 
    5458                { 
     
    5963                        elseif ($_POST['rewrite_subject']==1) 
    6064                        { 
    61                                 $rewrite_subject=$_POST['rewrite_subject_header']; 
     65                                $rewrite_subject=clean_input(trim($_POST['rewrite_subject_header'])); 
    6266                         
    6367                        } 
  • trunk/system_scripts/create_mailboxes.pl

    r171 r218  
    6666        my $id = $data[1]; 
    6767        my $emailaddr = $data[0]; 
     68        die ("Error: emailaddress contains illegal chars!\n") unless ($emailaddr=~m/^([a-zA-Z0-9._\-]+)$/); 
     69        die ("Error: domainname contains illegal chars!\n") unless ($dnsname=~m/^([a-zA-Z0-9._\-]+)$/); 
    6870        if ( ! -d "$config{'vmail_home'}/$dnsname") { 
    6971                `mkdir -p $config{'vmail_home'}/$dnsname`; 
  • trunk/templates/error_messages.tpl

    r207 r218  
    33{elseif $if_error_domain_exits == 'y' } 
    44{t}domain already exists!{/t} 
     5{elseif $if_error_domain_wrong == 'y'} 
     6{t}domainname contains illegal characters!{/t} 
    57{elseif $if_error_email_exits == 'y' } 
    68{t}emailaddress already exists!{/t} 
     
    4042{elseif $if_new_passwd_not_same == 'y'} 
    4143{t}new passwords does not match!{/t} 
     44{elseif $if_illegal_sa_subjecttag == 'y'} 
     45{t}subject contains illegal characters!{/t} 
    4246{elseif $if_submit_email_wrong == 'y' } 
    4347{t}emailaddress is not valid!{/t}