bd912dd8 |
/*
* Phishing module: domain list implementation.
* |
2023340a |
* Copyright (C) 2007-2008 Sourcefire, Inc.
*
* Authors: Török Edvin |
bd912dd8 |
*
* This program is free software; you can redistribute it and/or modify |
2023340a |
* it under the terms of the GNU General Public License version 2 as |
38a00199 |
* published by the Free Software Foundation. |
bd912dd8 |
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif
#ifdef CL_THREAD_SAFE
#ifndef _REENTRANT
#define _REENTRANT
#endif
#endif
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "clamav.h"
#include "others.h" |
b5341ac0 |
#include "phishcheck.h" |
bd912dd8 |
#include "phish_domaincheck_db.h"
#include "regex_list.h"
|
08402afa |
int domainlist_match(const struct cl_engine* engine,char* real_url,const char* display_url,const struct pre_fixup_info* pre_fixup,int hostOnly) |
bd912dd8 |
{
const char* info; |
b5341ac0 |
int rc = engine->domainlist_matcher ? regex_list_match(engine->domainlist_matcher,real_url,display_url,hostOnly ? pre_fixup : NULL,hostOnly,&info,0) : 0; |
bd912dd8 |
return rc;
}
|
3da4dd4c |
int init_domainlist(struct cl_engine* engine) |
bd912dd8 |
{ |
3da4dd4c |
if(engine) { |
85820f97 |
engine->domainlist_matcher = (struct regex_matcher *) cli_malloc(sizeof(struct regex_matcher)); |
241e7eb1 |
if(!engine->domainlist_matcher) {
cli_errmsg("Phishcheck: Unable to allocate memory for init_domainlist\n"); |
3da4dd4c |
return CL_EMEM; |
241e7eb1 |
} |
1e2969a4 |
#ifdef USE_MPOOL |
b36e9f8a |
((struct regex_matcher*)engine->domainlist_matcher)->mempool = engine->mempool; |
1e2969a4 |
#endif |
5b74e89a |
return init_regex_list(engine->domainlist_matcher, engine->dconf->other&OTHER_CONF_PREFILTERING); |
ec481027 |
} |
3da4dd4c |
else
return CL_ENULLARG; |
bd912dd8 |
}
|
3da4dd4c |
int is_domainlist_ok(const struct cl_engine* engine) |
bd912dd8 |
{ |
3da4dd4c |
return (engine && engine->domainlist_matcher) ? is_regex_ok(engine->domainlist_matcher) : 1; |
bd912dd8 |
}
|
3da4dd4c |
void domainlist_done(struct cl_engine* engine) |
bd912dd8 |
{ |
3da4dd4c |
if(engine && engine->domainlist_matcher) {
regex_list_done(engine->domainlist_matcher);
free(engine->domainlist_matcher);
} |
bd912dd8 |
}
|