]> source.dussan.org Git - rspamd.git/commitdiff
* Fix another spf core dump while parsing 'include' items
authorcebka@lenovo-laptop <cebka@lenovo-laptop>
Mon, 15 Mar 2010 17:54:39 +0000 (20:54 +0300)
committercebka@lenovo-laptop <cebka@lenovo-laptop>
Mon, 15 Mar 2010 17:54:39 +0000 (20:54 +0300)
conf/lotto.inc
perl/lib/Mail/Rspamd/Client.pm
rspamc.pl.in
src/spf.c

index 40cb98f2a114e5fd46e2b161c5035ac2f890665b..1df1a4c0b137e9771743c569ab604d92cacdb59c 100644 (file)
@@ -12,5 +12,5 @@ $__KAM_LOTTO5="/(freelotto group|Royal Heritage Lottery|UK National (Online)? Lo
 $__KAM_LOTTO6="/(Dear Lucky Winner|Winning Notification|Attention:Winner|Dear Winner)/isrP";
 $__KAM_LOTTO7="Subject=/(Your Lucky Day|(Attention:|ONLINE) WINNER)/iH";
 $KAM_LOTTO1="regexp_match_number(3, ${__KAM_LOTTO1}, ${__KAM_LOTTO2}, ${__KAM_LOTTO3}, ${__KAM_LOTTO4}, ${__KAM_LOTTO5}, ${__KAM_LOTTO6}, ${__KAM_LOTTO7})";
-#$R_LOTTO="regexp_match_number(3, ${__KAM_LOTTO1},  ${__KAM_LOTTO2}, ${__KAM_LOTTO3}, ${__KAM_LOTTO4}, ${__KAM_LOTTO5}, ${__KAM_LOTTO6})";
+$R_LOTTO="regexp_match_number(3, ${__KAM_LOTTO1},  ${__KAM_LOTTO2}, ${__KAM_LOTTO3}, ${__KAM_LOTTO4}, ${__KAM_LOTTO5}, ${__KAM_LOTTO6})";
 
index f026de8cc7c9e1da5ca034bd82e1a8a564e8f32b..9460b1ee9c2655baeb6bf3dcd05949517c43a751 100644 (file)
@@ -28,6 +28,7 @@ the spamd protocol.
 package Mail::Rspamd::Client;
 
 use IO::Socket;
+use Carp;
 
 use vars qw($VERSION);
 $VERSION = "1.02";
@@ -125,7 +126,7 @@ sub make_ssl_socket {
        eval {
                require IO::Socket::SSL;
                IO::Socket::SSL->import(LIST);
-       } or$self->{error} = "IO::Socket::SSL required for imaps";
+       } or croak "IO::Socket::SSL required for imaps";
 
        return IO::Socket::SSL->new("$host:$port");
 }
@@ -240,6 +241,7 @@ C<$is_check_p> either calls PROCESS or CHECK.
 
 The return value is a hash reference containing metrics indexed by name. Each metric
 is hash that contains data:
+
 =over 
 =item *
 isspam
@@ -275,6 +277,7 @@ This method makes a call to the spamd server
 
 The return value is a hash reference containing metrics indexed by name. Each metric
 is hash that contains data:
+
 =over
 =item *
 isspam
@@ -1205,7 +1208,7 @@ sub process_imap {
                        chomp $password;
                        Term::ReadKey->ReadMode('normal');
                        $self->{error} = "\n";
-               } or die "cannot get password. Check that Term::ReadKey is installed";
+               } or croak "cannot get password. Check that Term::ReadKey is installed";
        }
 
        # Stupid code that does not take care of timeouts etc, just trying to extract messages
index ba00d5a5ca13b2ece42977a82aa9c4c3f7f459e9..efadde0a2bdd60bcc09de98ef47e5b47692627ab 100755 (executable)
@@ -23,6 +23,7 @@ my %cfg = (
        'deliver_to'=>  '',
        'weight'    =>  1,
        'imap_search' => 'ALL',
+       'ip'            => '127.0.0.1',
 );
 
 my $terminal;
@@ -42,6 +43,7 @@ Additional options:
 -d         define deliver-to header
 -w         define weight for fuzzy operations
 -S         define search string for IMAP operations
+-i         emulate that message was send from specified IP
 
 Notes:
 imap format: imap:user:<username>:password:[<password>]:host:<hostname>:mbox:<mboxname>
@@ -184,7 +186,7 @@ my %args;
 
 HELP_MESSAGE() unless scalar @ARGV >= 1;
 
-getopt('c:h:P:s:d:w:S:H:', \%args);
+getopt('c:h:P:s:d:w:S:H:i:', \%args);
 
 my $cmd = shift;
 my @path = shift;
@@ -229,6 +231,9 @@ if (defined ($args{d})) {
 if (defined ($args{w})) {
        $cfg{'weight'} = $args{w};
 }
+if (defined ($args{i})) {
+       $cfg{'ip'} = $args{i};
+}
 
 if ($cmd =~ /(SYMBOLS|PROCESS|CHECK|URLS|EMAILS)/i) {
     $cfg{'command'} = $1;
index 798803a027030b4204ba591b200b3e7371e08938..0ff92303cf49df71b01b7b0361b58c740f73d90f 100644 (file)
--- a/src/spf.c
+++ b/src/spf.c
@@ -314,6 +314,11 @@ spf_record_dns_callback (int result, char type, int count, int ttl, void *addres
                                                                                        cb->rec->addrs->prev = elt->prev;
                                                                                }
 
+                                                                               /* Shift temporary list */
+                                                                               while (tmp->prev) {
+                                                                                       tmp = tmp->prev;
+                                                                               }
+
                                                                                cb->rec->addrs = tmp;
                                                                                g_list_free1 (elt);
                                                                        }
@@ -370,8 +375,8 @@ spf_record_dns_callback (int result, char type, int count, int ttl, void *addres
 
        cb->rec->task->save.saved--;
        if (cb->rec->task->save.saved == 0 && cb->rec->callback) {
+               cb->rec->callback (cb->rec, cb->rec->task);
                if (cb->rec->addrs) {
-                       cb->rec->callback (cb->rec, cb->rec->task);
                        g_list_free (cb->rec->addrs);
                        cb->rec->addrs = NULL;
                }