Skip to content

Commit

Permalink
detect/tls.certs: fix direction handling
Browse files Browse the repository at this point in the history
Direction flag was checked against wrong field, leading to undefined behavior.

Bug: OISF#6778.
  • Loading branch information
victorjulien committed Feb 14, 2024
1 parent 2242d10 commit 3c06457
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/detect-tls-certs.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ static int g_tls_certs_buffer_id = 0;
struct TlsCertsGetDataArgs {
uint32_t local_id; /**< used as index into thread inspect array */
SSLCertsChain *cert;
const uint8_t flags;
};

typedef struct PrefilterMpmTlsCerts {
Expand Down Expand Up @@ -148,7 +149,7 @@ static InspectionBuffer *TlsCertsGetData(DetectEngineThreadCtx *det_ctx,
const SSLState *ssl_state = (SSLState *)f->alstate;
const SSLStateConnp *connp;

if (f->flags & STREAM_TOSERVER) {
if (cbdata->flags & STREAM_TOSERVER) {
connp = &ssl_state->client_connp;
} else {
connp = &ssl_state->server_connp;
Expand Down Expand Up @@ -183,7 +184,7 @@ static uint8_t DetectEngineInspectTlsCerts(DetectEngineCtx *de_ctx, DetectEngine
transforms = engine->v2.transforms;
}

struct TlsCertsGetDataArgs cbdata = { 0, NULL };
struct TlsCertsGetDataArgs cbdata = { .local_id = 0, .cert = NULL, .flags = flags };

while (1)
{
Expand Down Expand Up @@ -214,7 +215,7 @@ static void PrefilterTxTlsCerts(DetectEngineThreadCtx *det_ctx, const void *pect
const MpmCtx *mpm_ctx = ctx->mpm_ctx;
const int list_id = ctx->list_id;

struct TlsCertsGetDataArgs cbdata = { 0, NULL };
struct TlsCertsGetDataArgs cbdata = { .local_id = 0, .cert = NULL, .flags = flags };

while (1)
{
Expand Down

0 comments on commit 3c06457

Please sign in to comment.