Skip to content

Commit

Permalink
frames: do not rely on FRAME_STREAM_ID
Browse files Browse the repository at this point in the history
As it is not always the first frame to be created :
if it is not enabled, it does not get created, and other enabled
frames may be created first. see use of FrameConfigTypeIsEnabled

This resulted that this other frame got its length updated
on stream end, which led to false positives.

Resorting on FRAME_STREAM_TYPE is more consistent.

Ticket: 7213
(cherry picked from commit 89d229c)
  • Loading branch information
catenacyber committed Sep 11, 2024
1 parent 98fd40a commit 8d7ac1c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/app-layer-frames.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

/** max 63 to fit the 64 bit per protocol space */
#define FRAME_STREAM_TYPE 63
/** always the first frame to be created. TODO but what about protocol upgrades? */
#define FRAME_STREAM_ID 1

typedef int64_t FrameId;

Expand Down
4 changes: 2 additions & 2 deletions src/app-layer-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ static void HandleStreamFrames(Flow *f, StreamSlice stream_slice, const uint8_t
if (((direction == 0 && (pstate->flags & APP_LAYER_PARSER_SFRAME_TS) == 0) ||
(direction == 1 && (pstate->flags & APP_LAYER_PARSER_SFRAME_TC) == 0)) &&
input != NULL && f->proto == IPPROTO_TCP) {
Frame *frame = AppLayerFrameGetById(f, direction, FRAME_STREAM_ID);
Frame *frame = AppLayerFrameGetLastOpenByType(f, direction, FRAME_STREAM_TYPE);
if (frame == NULL) {
int64_t frame_len = -1;
if (flags & STREAM_EOF)
Expand All @@ -1273,7 +1273,7 @@ static void HandleStreamFrames(Flow *f, StreamSlice stream_slice, const uint8_t
}
}
} else if (flags & STREAM_EOF) {
Frame *frame = AppLayerFrameGetById(f, direction, FRAME_STREAM_ID);
Frame *frame = AppLayerFrameGetLastOpenByType(f, direction, FRAME_STREAM_TYPE);
SCLogDebug("EOF closing: frame %p", frame);
if (frame) {
/* calculate final frame length */
Expand Down

0 comments on commit 8d7ac1c

Please # to comment.