From: Victor Julien Date: Fri, 2 Sep 2022 11:07:09 +0000 (+0200) Subject: detect/frames: minor cleanup in buffer handling X-Git-Tag: suricata-7.0.0-rc1~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f773b714e98c20c13768608ef9843e10a354b8d9;p=thirdparty%2Fsuricata.git detect/frames: minor cleanup in buffer handling Don't lookup a buffer twice, even if the lookup should be fast. --- diff --git a/src/detect-engine-frame.c b/src/detect-engine-frame.c index 2eaae4267a..d9408fe492 100644 --- a/src/detect-engine-frame.c +++ b/src/detect-engine-frame.c @@ -202,6 +202,8 @@ struct FrameStreamData { uint32_t idx; uint64_t frame_data_offset_abs; uint64_t frame_start_offset_abs; + /** buffer is set if callback was successful */ + InspectionBuffer *buffer; }; static int FrameStreamDataFunc( @@ -271,6 +273,7 @@ static int FrameStreamDataFunc( InspectionBufferSetupMulti(buffer, fsd->transforms, data, data_len); buffer->inspect_offset = frame->rel_offset < 0 ? -1 * frame->rel_offset : 0; // TODO review/test buffer->flags = ci_flags; + fsd->buffer = buffer; return 1; // for now only the first chunk } @@ -343,13 +346,10 @@ InspectionBuffer *DetectFrame2InspectBuffer(DetectEngineThreadCtx *det_ctx, return NULL; struct FrameStreamData fsd = { det_ctx, transforms, frame, list_id, idx, offset, - (uint64_t)frame_start_abs_offset }; + (uint64_t)frame_start_abs_offset, NULL }; StreamReassembleForFrame(ssn, stream, FrameStreamDataFunc, &fsd, offset, eof); SCLogDebug("offset %" PRIu64, offset); - - InspectionBuffer *ret = InspectionBufferMultipleForListGet(det_ctx, list_id, idx); - SCLogDebug("ret %p", ret); - return ret; + return fsd.buffer; } /**