You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2007/06/20 15:26:39 UTC
svn commit: r549103 - in /spamassassin/trunk: MANIFEST spamc/libspamc.c
t/spamc_H.t
Author: jm
Date: Wed Jun 20 06:26:38 2007
New Revision: 549103
URL: http://svn.apache.org/viewvc?view=rev&rev=549103
Log:
bug 5462: spamc -H randomization was broken; fix
Added:
spamassassin/trunk/t/spamc_H.t (with props)
Modified:
spamassassin/trunk/MANIFEST
spamassassin/trunk/spamc/libspamc.c
Modified: spamassassin/trunk/MANIFEST
URL: http://svn.apache.org/viewvc/spamassassin/trunk/MANIFEST?view=diff&rev=549103&r1=549102&r2=549103
==============================================================================
--- spamassassin/trunk/MANIFEST (original)
+++ spamassassin/trunk/MANIFEST Wed Jun 20 06:26:38 2007
@@ -500,3 +500,4 @@
t/root_spamd_x.t
t/root_spamd_x_paranoid.t
t/root_spamd_virtual.t
+t/spamc_H.t
Modified: spamassassin/trunk/spamc/libspamc.c
URL: http://svn.apache.org/viewvc/spamassassin/trunk/spamc/libspamc.c?view=diff&rev=549103&r1=549102&r2=549103
==============================================================================
--- spamassassin/trunk/spamc/libspamc.c (original)
+++ spamassassin/trunk/spamc/libspamc.c Wed Jun 20 06:26:38 2007
@@ -1740,6 +1740,7 @@
while (rnum-- > 0) {
tmp = tp->hosts[0];
+ /* TODO: free using freeaddrinfo() */
for (i = 1; i < tp->nhosts; i++)
tp->hosts[i - 1] = tp->hosts[i];
@@ -1765,7 +1766,7 @@
int transport_setup(struct transport *tp, int flags)
{
#ifdef SPAMC_HAS_ADDRINFO
- struct addrinfo hints, *res;
+ struct addrinfo hints, *res, *addrp;
char port[6];
#else
struct hostent *hp;
@@ -1878,6 +1879,13 @@
case EAI_FAIL: /*name server returned permanent error*/
errbits |= 2;
break;
+ default:
+ /* should not happen, all errors are checked above */
+ free(hostlist);
+ return EX_OSERR;
+ }
+ goto nexthost; /* try next host in list */
+ }
#else
if ((hp = gethostbyname(hostname)) == NULL) {
int origerr = h_errno; /* take a copy before syslog() */
@@ -1892,7 +1900,6 @@
case NO_RECOVERY:
errbits |= 2;
break;
-#endif
default:
/* should not happen, all errors are checked above */
free(hostlist);
@@ -1900,16 +1907,18 @@
}
goto nexthost; /* try next host in list */
}
+#endif
/* If we have no hosts at all */
#ifdef SPAMC_HAS_ADDRINFO
- if(res == NULL) {
+ if(res == NULL)
#else
if (hp->h_addr_list[0] == NULL
|| hp->h_length != sizeof tp->hosts[0]
- || hp->h_addrtype != AF_INET) {
+ || hp->h_addrtype != AF_INET)
/* no hosts/bad size/wrong family */
#endif
+ {
errbits |= 1;
goto nexthost; /* try next host in list */
}
@@ -1926,8 +1935,12 @@
TRANSPORT_MAX_HOSTS);
break;
}
- tp->hosts[tp->nhosts] = res;
- tp->nhosts++;
+ for (addrp = res; addrp != NULL; ) {
+ tp->hosts[tp->nhosts] = addrp;
+ addrp = addrp->ai_next; /* before NULLing ai_next */
+ tp->hosts[tp->nhosts]->ai_next = NULL;
+ tp->nhosts++;
+ }
#else
for (addrp = hp->h_addr_list; *addrp; addrp++) {
if (tp->nhosts == TRANSPORT_MAX_HOSTS) {
Added: spamassassin/trunk/t/spamc_H.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/spamc_H.t?view=auto&rev=549103
==============================================================================
--- spamassassin/trunk/t/spamc_H.t (added)
+++ spamassassin/trunk/t/spamc_H.t Wed Jun 20 06:26:38 2007
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+
+use lib '.'; use lib 't';
+use SATest; sa_t_init("spamc_H");
+
+# only run for localhost!
+our $DO_RUN = conf_bool('run_net_tests')
+ && !$SKIP_SPAMD_TESTS
+ && ($spamdhost eq '127.0.0.1');
+
+use Test; plan tests => ($DO_RUN ? 5 : 0);
+
+exit unless $DO_RUN;
+
+# ---------------------------------------------------------------------------
+
+%patterns = (
+
+q{ X-Spam-Flag: YES}, 'flag',
+q{ TEST_ENDSNUMS}, 'endsinnums',
+
+);
+
+ok(start_spamd("-L"));
+
+$spamdhost = 'multihomed.dnsbltest.spamassassin.org';
+ok(spamcrun("--connect-retries=100 -H < data/spam/001",
+ \&patterns_run_cb));
+ok_all_patterns();
+ok(stop_spamd());
Propchange: spamassassin/trunk/t/spamc_H.t
------------------------------------------------------------------------------
svn:executable = *