goto error;
cd->depth = depth;
cd->offset = offset;
- if (!is_cs)
+ if (!is_cs) {
+ BoyerMooreCtxToNocase(cd->bm_ctx, cd->content, cd->content_len);
cd->flags |= DETECT_CONTENT_NOCASE;
+ }
if (depth < cd->content_len)
goto error;
-/* Copyright (C) 2007-2012 Open Information Security Foundation
+/* Copyright (C) 2007-2014 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
goto error;
}
- filemagic->bm_ctx = BoyerMooreCtxInit(filemagic->name, filemagic->len);
+ filemagic->bm_ctx = BoyerMooreNocaseCtxInit(filemagic->name, filemagic->len);
if (filemagic->bm_ctx == NULL) {
goto error;
}
SCLogDebug("negated filemagic");
}
- BoyerMooreCtxToNocase(filemagic->bm_ctx, filemagic->name, filemagic->len);
#ifdef DEBUG
if (SCLogDebugEnabled()) {
char *name = SCMalloc(filemagic->len + 1);
-/* Copyright (C) 2007-2012 Open Information Security Foundation
+/* Copyright (C) 2007-2014 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
goto error;
}
- filename->bm_ctx = BoyerMooreCtxInit(filename->name, filename->len);
+ filename->bm_ctx = BoyerMooreNocaseCtxInit(filename->name, filename->len);
if (filename->bm_ctx == NULL) {
goto error;
}
SCLogDebug("negated filename");
}
- BoyerMooreCtxToNocase(filename->bm_ctx, filename->name, filename->len);
#ifdef DEBUG
if (SCLogDebugEnabled()) {
char *name = SCMalloc(filename->len + 1);
}
/**
- * \brief Setup a Booyer More context.
+ * \brief Setup a Booyer Moore context.
*
* \param str pointer to the pattern string
* \param size length of the string
}
/**
- * \brief Free the memory allocated to Booyer More context.
+ * \brief Setup a Booyer Moore context for nocase search
+ *
+ * \param str pointer to the pattern string
+ * \param size length of the string
+ * \retval BmCtx pointer to the newly created Context for the pattern
+ * \initonly BoyerMoore contexts should be created at init
+ */
+BmCtx *BoyerMooreNocaseCtxInit(uint8_t *needle, uint16_t needle_len)
+{
+ BmCtx *bm_ctx = BoyerMooreCtxInit(needle, needle_len);
+
+ BoyerMooreCtxToNocase(bm_ctx, needle, needle_len);
+
+ return bm_ctx;
+}
+
+/**
+ * \brief Free the memory allocated to Booyer Moore context.
*
* \param bmCtx pointer to the Context for the pattern
*/
/** Prepare and return a Boyer Moore context */
BmCtx *BoyerMooreCtxInit(uint8_t *needle, uint16_t needle_len);
+BmCtx *BoyerMooreNocaseCtxInit(uint8_t *needle, uint16_t needle_len);
void BoyerMooreCtxToNocase(BmCtx *, uint8_t *, uint16_t);
uint8_t *BoyerMoore(uint8_t *x, uint16_t m, uint8_t *y, int32_t n, BmCtx *bm_ctx);
*/
uint8_t *BoyerMooreNocaseSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen)
{
- BmCtx *bm_ctx = BoyerMooreCtxInit(needle, needlelen);
- BoyerMooreCtxToNocase(bm_ctx, needle, needlelen);
+ BmCtx *bm_ctx = BoyerMooreNocaseCtxInit(needle, needlelen);
uint8_t *ret = BoyerMooreNocase(needle, needlelen, text, textlen, bm_ctx);
BoyerMooreCtxDeInit(bm_ctx);
return NULL;
memcpy(needle, in_needle, needlelen);
- BmCtx *bm_ctx = BoyerMooreCtxInit(needle, needlelen);
- BoyerMooreCtxToNocase(bm_ctx, needle, needlelen);
+ BmCtx *bm_ctx = BoyerMooreNocaseCtxInit(needle, needlelen);
uint8_t *ret = NULL;
int i = 0;
return NULL;
memcpy(needle, in_needle, needlelen);
- BmCtx *bm_ctx = BoyerMooreCtxInit(needle, needlelen);
+ BmCtx *bm_ctx = BoyerMooreNocaseCtxInit(needle, needlelen);
uint8_t *ret = NULL;
int i = 0;
CLOCK_INIT;
if (times > 1) CLOCK_START;
for (i = 0; i < times; i++) {
- /* Stats including context building */
- BoyerMooreCtxToNocase(bm_ctx, needle, needlelen);
ret = BoyerMooreNocase(needle, needlelen, text, textlen, bm_ctx);
}
if (times > 1) { CLOCK_END; CLOCK_PRINT_SEC; };