Ticket #51: 0001-check_encrypted_size.patch

File 0001-check_encrypted_size.patch, 2.6 kB (added by mortonda@…, 4 years ago)
  • amavisd-maia

    diff --git a/amavisd-maia b/amavisd-maia
    index 589056a..9ed4205 100755
    a b  
    37383738 
    37393739 
    37403740# Store e-mail in the database 
    3741 sub maia_store_mail($$$$$@) { 
    3742     my($dbh, $msginfo, $oversized, $enable_stats_tracking, $system_default_user_is_local, @local_domain_tables) = @_; 
     3741sub maia_store_mail($$\$$$@) { 
     3742    my($dbh, $msginfo, $oversized, $size_limit, $enable_stats_tracking, $system_default_user_is_local, @local_domain_tables) = @_; 
    37433743    my($insert, $select, $sth, $sth2, $sth3, @row, @row2, $contents); 
    37443744    my $size = $1 if ($msginfo->orig_header_size + 1 + $msginfo->orig_body_size) =~ m/^([0-9]+)$/; # untaint 
    37453745    $size = untaint($size); 
     
    37483748    my $subject = ""; 
    37493749    my($header, $mail_id, $recipient, $user_id); 
    37503750    my($received_date) = strftime("%Y-%m-%d %H:%M:%S",localtime); 
    3751     if (!$oversized) { 
     3751    if (!$$oversized) { 
    37523752       my($fh) = $msginfo->mail_text; 
    37533753       $fh->seek(0,0) or die "Can't rewind mail file: $!"; 
    37543754       my(@lines) = <$fh>; 
     
    37563756       $contents =~ s/\0//g; # strip nulls 
    37573757       if (defined $encryption_key) { 
    37583758           $contents = maia_encrypt_text($encryption_key, $contents); 
     3759           { 
     3760               use bytes; 
     3761               my $encrypted_size = length($contents); 
     3762               $$oversized = $encrypted_size > $size_limit; 
     3763               if ($$oversized) { 
     3764                   do_log(3, sprintf("Maia: [maia_store_mail] WARNING: Size limit (%ld) > size of encrypted message (%ld); changing to oversized status.", 
     3765                          $size_limit, $encrypted_size)); 
     3766               } 
     3767           } 
    37593768       } 
    37603769       $contents = untaint($contents); 
    37613770    } 
     
    37773786    $subject = untaint($subject); 
    37783787    $sender = substr($sender, 0, 255) if length($sender) > 255; 
    37793788 
    3780     if (!$oversized) { 
     3789    if (!$$oversized) { 
    37813790        if ($dbtype =~ /^mysql$/si) { # MySQL 
    37823791 
    37833792            $insert = "INSERT INTO maia_mail (received_date, size, sender_email, envelope_to, subject, contents) VALUES (NOW(),?,?,?,?,?)"; 
     
    93489357    } 
    93499358 
    93509359    # write mail to maia_mail table 
    9351     $mail_id = maia_store_mail($dbh, $msginfo, $oversized, $enable_stats_tracking, 
     9360    $mail_id = maia_store_mail($dbh, $msginfo, $oversized, $size_limit, $enable_stats_tracking, 
    93529361                               $system_default_user_is_local, 
    93539362                               $local_domains_ldap, \%local_domains, 
    93549363                               \@local_domains_acl, $local_domains_re);