Skip to content

Commit

Permalink
protodetect: simplify app-layer-detect-proto.c code since DCERPC UDP …
Browse files Browse the repository at this point in the history
…detection is improved
  • Loading branch information
ilya-bakhtin committed Jul 22, 2024
1 parent b1fc6b1 commit f358da2
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions src/app-layer-detect-proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,6 @@ AppProto AppLayerProtoDetectGetProto(AppLayerProtoDetectThreadCtx *tctx, Flow *f
(flags & STREAM_TOSERVER) ? "toserver" : "toclient");

AppProto alproto = ALPROTO_UNKNOWN;
AppProto pm_alproto = ALPROTO_UNKNOWN;

if (!FLOW_IS_PM_DONE(f, flags)) {
AppProto pm_results[ALPROTO_MAX];
Expand All @@ -1419,38 +1418,24 @@ AppProto AppLayerProtoDetectGetProto(AppLayerProtoDetectThreadCtx *tctx, Flow *f
FLOW_RESET_PP_DONE(f, reverse_dir);
}
}

/* HACK: if detected protocol is dcerpc/udp, we run PP as well
* to avoid misdetecting DNS as DCERPC. */
if (!(ipproto == IPPROTO_UDP && alproto == ALPROTO_DCERPC))
goto end;

pm_alproto = alproto;

/* fall through */
SCReturnUInt(alproto);
}
}

if (!FLOW_IS_PP_DONE(f, flags)) {
bool rflow = false;
alproto = AppLayerProtoDetectPPGetProto(f, buf, buflen, ipproto, flags, &rflow);
*reverse_flow = false; /* to be safe if it was changed by PM */
alproto = AppLayerProtoDetectPPGetProto(f, buf, buflen, ipproto, flags, reverse_flow);
if (AppProtoIsValid(alproto)) {
if (rflow) {
*reverse_flow = true;
}
goto end;
SCReturnUInt(alproto);
}
}

/* Look if flow can be found in expectation list */
if (!FLOW_IS_PE_DONE(f, flags)) {
*reverse_flow = false; /* to be safe if it was changed by PP */
alproto = AppLayerProtoDetectPEGetProto(f, flags);
}

end:
if (!AppProtoIsValid(alproto))
alproto = pm_alproto;

SCReturnUInt(alproto);
}

Expand Down

0 comments on commit f358da2

Please sign in to comment.