Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next/20220325/v1 #7172

Merged
merged 8 commits into from
Mar 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/alert-debuglog.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "util-unittest.h"

#include "util-debug.h"
#include "util-validate.h"
#include "util-buffer.h"

#include "output.h"
Expand Down Expand Up @@ -175,7 +176,8 @@ static TmEcode AlertDebugLogger(ThreadVars *tv, const Packet *p, void *thread_da
if (PKT_IS_IPV4(p)) {
PrintInet(AF_INET, (const void *)GET_IPV4_SRC_ADDR_PTR(p), srcip, sizeof(srcip));
PrintInet(AF_INET, (const void *)GET_IPV4_DST_ADDR_PTR(p), dstip, sizeof(dstip));
} else if (PKT_IS_IPV6(p)) {
} else {
DEBUG_VALIDATE_BUG_ON(!(PKT_IS_IPV6(p)));
PrintInet(AF_INET6, (const void *)GET_IPV6_SRC_ADDR(p), srcip, sizeof(srcip));
PrintInet(AF_INET6, (const void *)GET_IPV6_DST_ADDR(p), dstip, sizeof(dstip));
}
Expand Down
3 changes: 1 addition & 2 deletions src/app-layer-htp-body.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@

#include "util-memcmp.h"

static StreamingBufferConfig default_cfg = {
0, 0, 3072, HTPMalloc, HTPCalloc, HTPRealloc, HTPFree };
static StreamingBufferConfig default_cfg = { 0, 3072, HTPMalloc, HTPCalloc, HTPRealloc, HTPFree };

/**
* \brief Append a chunk of body to the HtpBody struct
Expand Down
2 changes: 0 additions & 2 deletions src/app-layer-htp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2541,7 +2541,6 @@ static void HTPConfigSetDefaultsPhase2(const char *name, HTPCfgRec *cfg_prec)

htp_config_register_request_line(cfg_prec->cfg, HTPCallbackRequestLine);

cfg_prec->request.sbcfg.flags = 0;
cfg_prec->request.sbcfg.buf_size = cfg_prec->request.inspect_window ?
cfg_prec->request.inspect_window : 256;
cfg_prec->request.sbcfg.buf_slide = 0;
Expand All @@ -2550,7 +2549,6 @@ static void HTPConfigSetDefaultsPhase2(const char *name, HTPCfgRec *cfg_prec)
cfg_prec->request.sbcfg.Realloc = HTPRealloc;
cfg_prec->request.sbcfg.Free = HTPFree;

cfg_prec->response.sbcfg.flags = 0;
cfg_prec->response.sbcfg.buf_size = cfg_prec->response.inspect_window ?
cfg_prec->response.inspect_window : 256;
cfg_prec->response.sbcfg.buf_slide = 0;
Expand Down
4 changes: 3 additions & 1 deletion src/app-layer-smtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,9 @@ static int SMTPProcessReply(SMTPState *state, Flow *f,
/* we are entering STARRTTLS data mode */
state->parser_state |= SMTP_PARSER_STATE_COMMAND_DATA_MODE;
AppLayerRequestProtocolTLSUpgrade(f);
SMTPTransactionComplete(state);
if (state->curr_tx) {
SMTPTransactionComplete(state);
}
} else {
/* decoder event */
SMTPSetEvent(state, SMTP_DECODER_EVENT_TLS_REJECTED);
Expand Down
27 changes: 27 additions & 0 deletions src/detect-content.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ int DetectContentDataParse(const char *keyword, const char *contentstr,
if (str[i] == '|') {
bin_count++;
if (bin) {
if (binpos > 0) {
SCLogError(SC_ERR_INVALID_SIGNATURE,
"Incomplete hex code in content - %s. Invalidating signature.",
contentstr);
goto error;
}
bin = 0;
} else {
bin = 1;
Expand Down Expand Up @@ -3050,6 +3056,25 @@ static int DetectLongContentTest3(void)
return !DetectLongContentTestCommon(sig, 1);
}

static int DetectBadBinContent(void)
{
DetectEngineCtx *de_ctx = NULL;
de_ctx = DetectEngineCtxInit();
FAIL_IF_NULL(de_ctx);
de_ctx->flags |= DE_QUIET;
FAIL_IF_NOT_NULL(DetectEngineAppendSig(
de_ctx, "alert tcp any any -> any any (msg:\"test\"; content:\"|a|\"; sid:1;)"));
FAIL_IF_NOT_NULL(DetectEngineAppendSig(
de_ctx, "alert tcp any any -> any any (msg:\"test\"; content:\"|aa b|\"; sid:1;)"));
FAIL_IF_NOT_NULL(DetectEngineAppendSig(
de_ctx, "alert tcp any any -> any any (msg:\"test\"; content:\"|aa bz|\"; sid:1;)"));
/* https://redmine.openinfosecfoundation.org/issues/5201 */
FAIL_IF_NOT_NULL(DetectEngineAppendSig(
de_ctx, "alert tcp any any -> any any (msg:\"test\"; content:\"|22 2 22|\"; sid:1;)"));
DetectEngineCtxFree(de_ctx);
PASS;
}

/**
* \brief this function registers unit tests for DetectContent
*/
Expand Down Expand Up @@ -3168,5 +3193,7 @@ static void DetectContentRegisterTests(void)
UtRegisterTest("DetectLongContentTest1", DetectLongContentTest1);
UtRegisterTest("DetectLongContentTest2", DetectLongContentTest2);
UtRegisterTest("DetectLongContentTest3", DetectLongContentTest3);

UtRegisterTest("DetectBadBinContent", DetectBadBinContent);
}
#endif /* UNITTESTS */
5 changes: 5 additions & 0 deletions src/detect-engine-build.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,11 @@ static int SignatureCreateMask(Signature *s)
case DETECT_ENGINE_EVENT:
s->mask |= SIG_MASK_REQUIRE_ENGINE_EVENT;
break;
}
}

for (sm = s->init_data->smlists[DETECT_SM_LIST_POSTMATCH]; sm != NULL; sm = sm->next) {
switch (sm->type) {
case DETECT_CONFIG: {
DetectConfigData *fd = (DetectConfigData *)sm->ctx;
if (fd->scope == CONFIG_SCOPE_FLOW) {
Expand Down
Loading