Merge branch 'master' of git.clam.sourcefire.com:/var/lib/git/clamav-devel

pull/8/merge
Steven Morgan 10 years ago
commit 5e7e16978d
  1. 2
      clamdscan/proto.c
  2. 38
      configure
  3. 49
      libclamav/matcher-pcre.c
  4. 11
      libclamav/matcher-pcre.h
  5. 2
      libclamav/ole2_extract.c
  6. 1
      libclamav/others.c
  7. 4
      libclamav/regex_pcre.c
  8. 2
      libclamav/regex_pcre.h
  9. 24
      m4/reorganization/libs/pcre.m4
  10. 1
      unit_tests/check_matchers.c

@ -23,8 +23,10 @@
#endif
#if defined(C_SOLARIS)
#ifndef __EXTENSIONS__
#define __EXTENSIONS__
#endif
#endif
/* must be first because it may define _XOPEN_SOURCE */
#include "shared/fdpassing.h"

38
configure vendored

@ -17651,18 +17651,31 @@ if test "x$found_pcre" != "xno"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcre.h in $PCRE_HOME" >&5
$as_echo_n "checking for pcre.h in $PCRE_HOME... " >&6; }
if test ! -f "$PCRE_HOME/include/pcre.h"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
$as_echo "not found" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
$as_echo "found" >&6; }
save_LIBS="$LIBS"
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $PCRE_CPPFLAGS"
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $PCRE_LIBS"
CPPFLAGS="$CPPFLAGS $PCRE_CPPFLAGS"
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $PCRE_LIBS"
ac_fn_c_check_header_mongrel "$LINENO" "pcre.h" "ac_cv_header_pcre_h" "$ac_includes_default"
if test "x$ac_cv_header_pcre_h" = xyes; then :
have_pcre="yes"
else
have_pcre="no"
fi
if test "x$have_pcre" = "xno"; then
ac_fn_c_check_header_mongrel "$LINENO" "pcre/pcre.h" "ac_cv_header_pcre_pcre_h" "$ac_includes_default"
if test "x$ac_cv_header_pcre_pcre_h" = xyes; then :
have_pcre="yes"
else
have_pcre="no"
fi
fi
if test "x$have_pcre" = "xyes"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcre_compile in -lpcre" >&5
$as_echo_n "checking for pcre_compile in -lpcre... " >&6; }
if ${ac_cv_lib_pcre_pcre_compile+:} false; then :
@ -17705,10 +17718,11 @@ else
have_pcre="no"
fi
fi
CPPFLAGS="$save_CPPFLAGS"
if test "x$have_pcre" = "xno"; then
CPPFLAGS="$save_CPPFLAGS"
LDFLAGS="$save_LDFLAGS"
LIBS="$save_LIBS"
fi
fi

@ -186,6 +186,11 @@ void cli_pcre_perf_events_destroy()
/* PCRE MATCHER FUNCTIONS */
int cli_pcre_init()
{
return cli_pcre_init_internal();
}
int cli_pcre_addpatt(struct cli_matcher *root, const char *virname, const char *trigger, const char *pattern, const char *cflags, const char *offset, const uint32_t *lsigid, unsigned int options)
{
struct cli_pcre_meta **newmetatable = NULL, *pm = NULL;
@ -790,6 +795,50 @@ void cli_pcre_freetable(struct cli_matcher *root)
#else
/* NO-PCRE FUNCTIONS */
void cli_pcre_perf_print()
{
cli_errmsg("cli_pcre_perf_print: Cannot print PCRE performance results without PCRE support\n");
return;
}
void cli_pcre_perf_events_destroy()
{
cli_errmsg("cli_pcre_perf_events_destroy: Cannot destroy PCRE performance results without PCRE support\n");
return;
}
int cli_pcre_init()
{
cli_errmsg("cli_pcre_init: Cannot initialize PCRE without PCRE support\n");
return CL_SUCCESS;
}
int cli_pcre_build(struct cli_matcher *root, long long unsigned match_limit, long long unsigned recmatch_limit, const struct cli_dconf *dconf)
{
UNUSEDPARAM(root);
UNUSEDPARAM(match_limit);
UNUSEDPARAM(recmatch_limit);
UNUSEDPARAM(dconf);
cli_errmsg("cli_pcre_build: Cannot build PCRE expression without PCRE support\n");
return CL_SUCCESS;
}
int cli_pcre_scanbuf(const unsigned char *buffer, uint32_t length, const char **virname, struct cli_ac_result **res, const struct cli_matcher *root, struct cli_ac_data *mdata, const struct cli_pcre_off *data, cli_ctx *ctx)
{
UNUSEDPARAM(buffer);
UNUSEDPARAM(length);
UNUSEDPARAM(virname);
UNUSEDPARAM(res);
UNUSEDPARAM(root);
UNUSEDPARAM(mdata);
UNUSEDPARAM(data);
UNUSEDPARAM(ctx);
cli_errmsg("cli_pcre_scanbuf: Cannot scan buffer with PCRE expression without PCRE support\n");
return CL_SUCCESS;
}
int cli_pcre_recaloff(struct cli_matcher *root, struct cli_pcre_off *data, struct cli_target_info *info, cli_ctx *ctx)
{
UNUSEDPARAM(root);

@ -36,7 +36,7 @@
#include "mpool.h"
#include "regex_pcre.h"
#define PNRE_SCAN_NONE 0
#define PCRE_SCAN_NONE 0
#define PCRE_SCAN_BUFF 1
#define PCRE_SCAN_FMAP 2
@ -73,6 +73,7 @@ void cli_pcre_perf_print();
void cli_pcre_perf_events_destroy();
/* PCRE MATCHER DECLARATIONS */
int cli_pcre_init();
int cli_pcre_addpatt(struct cli_matcher *root, const char *virname, const char *trigger, const char *pattern, const char *cflags, const char *offset, const uint32_t *lsigid, unsigned int options);
int cli_pcre_build(struct cli_matcher *root, long long unsigned match_limit, long long unsigned recmatch_limit, const struct cli_dconf *dconf);
int cli_pcre_recaloff(struct cli_matcher *root, struct cli_pcre_off *data, struct cli_target_info *info, cli_ctx *ctx);
@ -81,9 +82,15 @@ int cli_pcre_scanbuf(const unsigned char *buffer, uint32_t length, const char **
void cli_pcre_freemeta(struct cli_matcher *root, struct cli_pcre_meta *pm);
void cli_pcre_freetable(struct cli_matcher *root);
#else
/* NO-PCRE DECLARATIONS - defined because encasing everything in '#if' is a pain */
/* NO-PCRE DECLARATIONS - defined because encasing everything in '#if' is a pain and because dynamic library mappings are weird */
#define PCRE_BYPASS ""
void cli_pcre_perf_print();
void cli_pcre_perf_events_destroy();
int cli_pcre_init();
int cli_pcre_build(struct cli_matcher *root, long long unsigned match_limit, long long unsigned recmatch_limit, const struct cli_dconf *dconf);
int cli_pcre_scanbuf(const unsigned char *buffer, uint32_t length, const char **virname, struct cli_ac_result **res, const struct cli_matcher *root, struct cli_ac_data *mdata, const struct cli_pcre_off *data, cli_ctx *ctx);
int cli_pcre_recaloff(struct cli_matcher *root, struct cli_pcre_off *data, struct cli_target_info *info, cli_ctx *ctx);
void cli_pcre_freeoff(struct cli_pcre_off *data);
#endif /* HAVE_PCRE */

@ -403,7 +403,7 @@ ole2_read_block(ole2_header_t * hdr, void *buff, unsigned int size, int32_t bloc
return FALSE;
} else if (offend > hdr->m_length) {
/* bb#11369 - ole2 files may not be a block multiple in size */
bzero(buff, size);
memset(buff, 0, size);
size = hdr->m_length - offset;
}
if (!(pblock = fmap_need_off_once(hdr->map, offset, size))) {

@ -71,6 +71,7 @@
#include "regex/regex.h"
#include "ltdl.h"
#include "matcher-ac.h"
#include "matcher-pcre.h"
#include "default.h"
#include "scanners.h"
#include "bytecode.h"

@ -34,8 +34,8 @@
#include "others.h"
#include "regex_pcre.h"
/* TODO: cli_pcre_init: redefine pcre_malloc and pcre_free, setup callback function? */
int cli_pcre_init()
/* TODO: cli_pcre_init_internal: redefine pcre_malloc and pcre_free, setup callback function? */
int cli_pcre_init_internal()
{
pcre_malloc = cli_malloc;
pcre_free = free;

@ -48,7 +48,7 @@ struct cli_pcre_data {
uint32_t search_offset; /* start offset to search at for pcre_exec */
};
int cli_pcre_init();
int cli_pcre_init_internal();
int cli_pcre_addoptions(struct cli_pcre_data *pd, const char **opt, int errout);
int cli_pcre_compile(struct cli_pcre_data *pd, long long unsigned match_limit, long long unsigned match_limit_recursion, unsigned int options, int opt_override);
int cli_pcre_match(struct cli_pcre_data *pd, const unsigned char *buffer, uint32_t buflen, int override_offset, int options, int *ovector, size_t ovlen);

@ -86,21 +86,25 @@ have_pcre="no"
if test "x$found_pcre" != "xno"; then
AC_MSG_CHECKING([for pcre.h in $PCRE_HOME])
if test ! -f "$PCRE_HOME/include/pcre.h"; then
AC_MSG_RESULT([not found])
else
AC_MSG_RESULT([found])
save_LIBS="$LIBS"
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $PCRE_CPPFLAGS"
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $PCRE_LIBS"
dnl save_LIBS="$LIBS"
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $PCRE_CPPFLAGS"
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $PCRE_LIBS"
AC_CHECK_HEADER(pcre.h, [have_pcre="yes"], [have_pcre="no"])
if test "x$have_pcre" = "xno"; then
AC_CHECK_HEADER(pcre/pcre.h, [have_pcre="yes"], [have_pcre="no"])
fi
if test "x$have_pcre" = "xyes"; then
AC_CHECK_LIB([pcre], [pcre_compile], [have_pcre="yes"], [have_pcre="no"])
fi
if test "x$have_pcre" = "xno"; then
dnl LIBS="$save_LIBS"
CPPFLAGS="$save_CPPFLAGS"
LDFLAGS="$save_LDFLAGS"
LIBS="$save_LIBS"
fi
fi

@ -31,7 +31,6 @@
#include "../libclamav/matcher-ac.h"
#include "../libclamav/matcher-bm.h"
#include "../libclamav/matcher-pcre.h"
#include "../libclamav/regex_pcre.h"
#include "../libclamav/others.h"
#include "../libclamav/default.h"
#include "checks.h"

Loading…
Cancel
Save