~ubuntu-branches/ubuntu/jaunty/clamav/jaunty-updates

« back to all changes in this revision

Viewing changes to clamav-milter/whitelist.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman, Scott Kitterman, Jamie Strandboge
  • Date: 2009-04-10 21:57:17 UTC
  • Revision ID: james.westby@ubuntu.com-20090410215717-1rsik8ezsgkkeqom
Tags: 0.95.1+dfsg-0ubuntu1
[ Scott Kitterman ]
* New upstream bugfix release 
  - libclamav/others.h: harden CLI_ISCONTAINED macro (bb#1552)
  - libclamav/phishcheck.c: fix possible crash in cli_url_canon() (bb#1553)
  - Signficant clamav-milter bug fixes
  - Other fixes throughout
* Drop ArchiveLimitMemoryUsage option from clamav-base.postinst.in (option
  removed upstream)
* Add CommandReadTimeout, SendBufTimeout, and MaxQueue to
  clamav-base.postinst.in
* Add SkipAuthenticated to clamav-milter.postinst.in
* Drop unrar and lha from clamav Suggests since external unpackers are not
  supported since 0.94

[ Jamie Strandboge ]
* fix freshclam apparmor profile for klamav (LP: #359301)

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <stdio.h>
26
26
#include <string.h>
27
27
#include <sys/types.h>
28
 
#include <regex.h>
29
28
 
 
29
#include "libclamav/regex/regex.h"
30
30
#include "shared/output.h"
31
31
#include "whitelist.h"
32
32
 
38
38
struct WHLST *wfrom = NULL;
39
39
struct WHLST *wto = NULL;
40
40
 
 
41
int skipauth = 0;
 
42
regex_t authreg;
 
43
 
41
44
void whitelist_free(void) {
42
45
    struct WHLST *w;
43
46
    while(wfrom) {
44
47
        w = wfrom->next;
45
 
        regfree(&wfrom->preg);
 
48
        cli_regfree(&wfrom->preg);
46
49
        free(wfrom);
47
50
        wfrom = w;
48
51
    }
49
52
    while(wto) {
50
53
        w = wto->next;
51
 
        regfree(&wto->preg);
 
54
        cli_regfree(&wto->preg);
52
55
        free(wto);
53
56
        wto = w;
54
57
    }
85
88
        }
86
89
        if(!len) continue;
87
90
        if (!(w = (struct WHLST *)malloc(sizeof(*w)))) {
88
 
            logg("!Out of memory loading whitelist\n");
 
91
            logg("!Out of memory loading whitelist file\n");
89
92
            whitelist_free();
90
93
            return 1;
91
94
        }
92
95
        w->next = (*addto);
93
96
        (*addto) = w;
94
 
        if (regcomp(&w->preg, ptr, REG_ICASE|REG_NOSUB)) {
95
 
            logg("!Failed to compile regex '%s'\n", ptr);
 
97
        if (cli_regcomp(&w->preg, ptr, REG_ICASE|REG_NOSUB)) {
 
98
            logg("!Failed to compile regex '%s' in whitelist file\n", ptr);
96
99
            whitelist_free();
97
100
            return 1;
98
101
        }
108
111
    else w = wto;
109
112
 
110
113
    while(w) {
111
 
        if(!regexec(&w->preg, addr, 0, NULL, 0))
 
114
        if(!cli_regexec(&w->preg, addr, 0, NULL, 0))
112
115
            return 1;
113
116
        w = w->next;
114
117
    }
116
119
}
117
120
 
118
121
 
 
122
int smtpauth_init(const char *r) {
 
123
    if (cli_regcomp(&authreg, r, REG_ICASE|REG_NOSUB|REG_EXTENDED)) {
 
124
        logg("!Failed to compile regex '%s' for SkipAuthSenders\n", r);
 
125
        return 1;
 
126
    }
 
127
    skipauth = 1;
 
128
    return 0;
 
129
}
 
130
 
 
131
 
 
132
int smtpauthed(const char *login) {
 
133
    if(skipauth && !cli_regexec(&authreg, login, 0, NULL, 0))
 
134
        return 1;
 
135
    return 0;
 
136
}
 
137
 
 
138
 
119
139
/*
120
140
 * Local Variables:
121
141
 * mode: c