RE: [dspam-users] Example.c File

From: . kibble . <jelly_bean_junky@hotmail.com>
Date: Fri Sep 02 2005 - 09:16:02 EDT

As requested a snippet of code:
int report_spam(int spamflag) {

    int sflag = 0;
    char * message = malloc(1);
    DSPAM_CTX * CTX = NULL; /** DSPAM Context */
    struct _ds_spam_signature SIG; /** Example signature */

    message = read_emailmem(message);

    switch (spamflag) {
        case SPAMREPT: /** set up the context for error correction as
spam */
            log_write(0, LOG_MAIN, "LOG: SPAMREPT function reached");
            CTX = dspam_create((char *)sender_address, NULL, NULL,
DSM_PROCESS, DSF_CHAINED);
            CTX = attach_ctx_dbaccess(CTX);
            if (CTX == NULL) {
                log_write(0, LOG_MAIN, "ERROR: dspam_create failed!\n");
                sflag = 1;
            }
            CTX->classification = DSR_ISSPAM;
            CTX->source = DSS_ERROR;
            CTX->algorithms = DSA_GRAHAM | DSA_BURTON | DSP_GRAHAM;
            break;
        case FALSEPOS: /** set up the context for error correction as
innocent */
            log_write(0, LOG_MAIN, "LOG: FALSEPOS function reached");
            CTX = dspam_create((char *)sender_address, NULL, NULL,
DSM_PROCESS, DSF_CHAINED | DSF_SIGNATURE);
            CTX = attach_ctx_dbaccess(CTX);
            if (CTX == NULL) {
                log_write(0, LOG_MAIN, "ERROR: dspam_create failed!\n");
                sflag = 1;
            }
            CTX->classification = DSR_ISINNOCENT;
            CTX->source = DSS_ERROR;
            CTX->algorithms = DSA_GRAHAM | DSA_BURTON | DSP_GRAHAM;
            CTX->signature = &SIG; /** Attach the signature to the
context */
            break;
        default: /** no reporting required, scan for spam perhaps ? */
            log_write(0, LOG_MAIN, "report_spam -> no reporting required");
            break;
    }

    log_write(0, LOG_MAIN, "LOG: Processing spam...");
    if (dspam_process(CTX, message) != 0) { /** Call DSPAM */
        log_write(0, LOG_MAIN, "ERROR: dspam_process failed!");
        sflag = 1;
    }

    log_write(0, LOG_MAIN, "ERROR: report_spam: dspam_destroy beginning");
    dspam_destroy(CTX); /** Destroy the context */

    memset(message, 0x0, sizeof(message));
    free(message);
    memset(&CTX, 0x0, sizeof(CTX));
    free(CTX);

    if (sflag == 0) {
        log_write(0, LOG_MAIN, "<= %s [%s] P=%s A=%s:%s",
            (char *)sender_address, (char *)sender_host_address, (char
*)received_protocol,
            (char *)sender_host_authenticated, (char *)sender_address);
        log_write(0, LOG_MAIN, "=> (null) <%s> R=system_localuser
T=local_delivery",
            (char *)recipients_list[0].address);
    }

    /** if we are reporting, which is pretty much so if you reach here, we
blackhole the email */
    recipients_count = 0;

    return(sflag);
} /** report_spam */

>From: "Russ Fink" <russfink@hotmail.com>
>To: jelly_bean_junky@hotmail.com, dspam-users@lists.nuclearelephant.com
>Subject: RE: [dspam-users] Example.c File
>Date: Mon, 29 Aug 2005 10:47:57 -0400
>
>The dspam_process is intentionally called with NULL, because a retrain
>requires the CTX (context) to contain a valid message signature, not the
>message itself. It is in this way that dspam_process finds the appropriate
>tokens whose values need adjusting.
>
>If you want the list to help, we need more information. What platform are
>you using? Can you post a stack trace of the crash, using gdb or similar?
>What storage method are you using: Postgres, sqlite3, or other? Also, can
>you put code in to check that the CTX signature is valid (non-null, and
>meaningful)? May want to include a snippet of code if you are able.
>
>I have a hunch that there's a problem with the signature in your CTX.
>
>>From: ". kibble ." <jelly_bean_junky@hotmail.com>
>>To: dspam-users@lists.nuclearelephant.com
>>Subject: [dspam-users] Example.c File
>>Date: Fri, 26 Aug 2005 14:47:11 +0100
>>
>>
>>Hey there,
>>
>>I was reading thru the example.c file and I noticed in the 'False
>>Positive' section the line 253 where dspam_process is called that there is
>>a NULL value in the function call...
>>
>>Is this right, in my older code I'm using a pointer which contains the
>>message which I'am reporting as a false positive. The only thing is, it
>>crashes each time I do. Reporting, and general scanning works perfectly
>>but reporting a false positive causes the system to crash.
>>
>>I have tried the stable, beta and CVS versions and they all produce the
>>same results. Not sure what to do next? Any ideas...
>>
>>Regards, kibble.
>>
>
>
>

_________________________________________________________________
Want to block unwanted pop-ups? Download the free MSN Toolbar now!
http://toolbar.msn.co.uk/
Received on Fri Sep 2 09:17:06 2005

This archive was generated by hypermail 2.1.8 : Thu Sep 29 2005 - 13:51:29 EDT