]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_spam.c
* extract_token() now expects to be supplied with the size of the
[citadel.git] / citadel / serv_spam.c
index fd14ad0ac8678c8039e480d7b2d080b27c6f2da6..8cdca5648ba1551767a6dfff89609a82eb246705 100644 (file)
@@ -83,9 +83,9 @@ int spam_filter(struct CtdlMessage *msg) {
 
        if (spam_strings_found) {
                if (msg->cm_fields['0'] != NULL) {
-                       phree(msg->cm_fields['0']);
+                       free(msg->cm_fields['0']);
                }
-               msg->cm_fields['0'] = strdoop("Unsolicited spam rejected");
+               msg->cm_fields['0'] = strdup("Unsolicited spam rejected");
                return(spam_strings_found);
        }
 
@@ -105,6 +105,8 @@ int spam_assassin(struct CtdlMessage *msg) {
        char buf[SIZ];
        int is_spam = 0;
        int sa;
+       char *msgtext;
+       size_t msglen;
 
        /* For users who have authenticated to this server we never want to
         * apply spam filtering, because presumably they're trustworthy.
@@ -117,7 +119,7 @@ int spam_assassin(struct CtdlMessage *msg) {
 
        /* Try them one by one until we get a working one */
         for (sa=0; sa<num_sahosts; ++sa) {
-                extract(buf, sahosts, sa);
+                extract_token(buf, sahosts, sa, '|', sizeof buf);
                 lprintf(CTDL_INFO, "Connecting to SpamAssassin at <%s>\n", buf);
                 sock = sock_connect(buf, SPAMASSASSIN_PORT, "tcp");
                 if (sock >= 0) lprintf(CTDL_DEBUG, "Connected!\n");
@@ -136,9 +138,18 @@ int spam_assassin(struct CtdlMessage *msg) {
        sock_write(sock, buf, strlen(buf));
 
        /* Message */
-       CtdlRedirectOutput(NULL, sock);
+       CC->redirect_buffer = malloc(SIZ);
+       CC->redirect_len = 0;
+       CC->redirect_alloc = SIZ;
        CtdlOutputPreLoadedMsg(msg, 0L, MT_RFC822, HEADERS_ALL, 0, 1);
-       CtdlRedirectOutput(NULL, -1);
+       msgtext = CC->redirect_buffer;
+       msglen = CC->redirect_len;
+       CC->redirect_buffer = NULL;
+       CC->redirect_len = 0;
+       CC->redirect_alloc = 0;
+
+       sock_write(sock, msgtext, msglen);
+       free(msgtext);
 
        /* Close one end of the socket connection; this tells SpamAssassin
         * that we're done.
@@ -164,9 +175,9 @@ int spam_assassin(struct CtdlMessage *msg) {
 
        if (is_spam) {
                if (msg->cm_fields['0'] != NULL) {
-                       phree(msg->cm_fields['0']);
+                       free(msg->cm_fields['0']);
                }
-               msg->cm_fields['0'] = strdoop(
+               msg->cm_fields['0'] = strdup(
                        "5.7.1 Message rejected by SpamAssassin");
        }