Skip to content
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
2 changes: 1 addition & 1 deletion src/detect-engine-frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ static bool SetupStreamCallbackData(struct FrameStreamData *dst, const TcpSessio
if (usable <= frame_offset)
return false;

uint64_t want = frame->inspect_progress;
uint64_t want = frame->offset + frame->inspect_progress;
if (frame->len == -1) {
if (eof) {
want = usable;
Expand Down
10 changes: 2 additions & 8 deletions src/detect-flowint.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,15 @@ int DetectFlowintMatch(DetectEngineThreadCtx *det_ctx,
if (fv != NULL && fv->datatype == FLOWVAR_TYPE_INT) {
if (sfd->modifier == FLOWINT_MODIFIER_ADD) {
SCLogDebug("Adding %u to %s", targetval, sfd->name);
uint32_t val = UINT32_MAX;
if (targetval < UINT32_MAX - fv->data.fv_int.value) {
val = fv->data.fv_int.value + targetval;
}
uint32_t val = SCSaturateAddU32(fv->data.fv_int.value, targetval);
FlowVarAddIntNoLock(p->flow, sfd->idx, val);
ret = 1;
goto end;
}

if (sfd->modifier == FLOWINT_MODIFIER_SUB) {
SCLogDebug("Subtracting %u to %s", targetval, sfd->name);
uint32_t val = 0;
if (targetval < fv->data.fv_int.value) {
val = fv->data.fv_int.value - targetval;
}
uint32_t val = SCSaturateSubU32(fv->data.fv_int.value, targetval);
FlowVarAddIntNoLock(p->flow, sfd->idx, val);
ret = 1;
goto end;
Expand Down
2 changes: 1 addition & 1 deletion src/detect-tls-cert-serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void DetectTlsSerialRegister(void)
#ifdef UNITTESTS
sigmatch_table[DETECT_TLS_CERT_SERIAL].RegisterTests = DetectTlsSerialRegisterTests;
#endif
sigmatch_table[DETECT_TLS_CERT_SERIAL].flags |= SIGMATCH_NOOPT;
sigmatch_table[DETECT_TLS_CERT_SERIAL].flags |= SIGMATCH_OPTIONAL_OPT | SIGMATCH_SUPPORT_DIR;
sigmatch_table[DETECT_TLS_CERT_SERIAL].flags |= SIGMATCH_INFO_STICKY_BUFFER;

DetectAppLayerInspectEngineRegister("tls.cert_serial", ALPROTO_TLS, SIG_FLAG_TOCLIENT,
Expand Down
2 changes: 1 addition & 1 deletion src/output-json-frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ static int FrameJson(ThreadVars *tv, JsonFrameLogThread *aft, const Packet *p)
if (frame->flags & FRAME_FLAG_LOGGED)
continue;

int64_t abs_offset = (int64_t)frame->offset + (int64_t)STREAM_BASE_OFFSET(stream);
int64_t abs_offset = (int64_t)frame->offset;
int64_t win = STREAM_APP_PROGRESS(stream) - abs_offset;

/* skip frame if threshold not yet reached, esp if frame length is
Expand Down
12 changes: 11 additions & 1 deletion src/suricata-common.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2007-2022 Open Information Security Foundation
/* Copyright (C) 2007-2026 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
Expand Down Expand Up @@ -560,6 +560,16 @@ extern int coverage_unittests;
extern int g_ut_modules;
extern int g_ut_covered;

static inline uint32_t SCSaturateAddU32(uint32_t a, uint32_t b)
{
return a + b >= a ? a + b : UINT32_MAX;
}

static inline uint32_t SCSaturateSubU32(uint32_t a, uint32_t b)
{
return a < b ? 0 : a - b;
}

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))

#ifdef __cplusplus
Expand Down
Loading