From e982dd50d0396499d7e83f929eb6b548d52cbd9f Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Thu, 29 Jan 2026 21:21:11 +0100 Subject: [PATCH] smtp: use configured FTP ports in probing parser To allow users to configure more than port 21 Ticket: 6591 --- src/app-layer-detect-proto.c | 15 +++++++++++++++ src/app-layer-detect-proto.h | 2 ++ src/app-layer-smtp.c | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/app-layer-detect-proto.c b/src/app-layer-detect-proto.c index 0be4bcfc39..5036589999 100644 --- a/src/app-layer-detect-proto.c +++ b/src/app-layer-detect-proto.c @@ -460,6 +460,21 @@ static AppLayerProtoDetectProbingParserPort *AppLayerProtoDetectGetProbingParser SCReturnPtr(pp_port, "AppLayerProtoDetectProbingParserPort *"); } +bool AppLayerProtoDetectHasProbingParsers(uint8_t ipproto, uint16_t port, AppProto alproto) +{ + AppLayerProtoDetectProbingParserPort *p = + AppLayerProtoDetectGetProbingParsers(alpd_ctx.ctx_pp, ipproto, port); + if (p == NULL) + return false; + AppLayerProtoDetectProbingParserElement *dp = p->dp; + while (dp) { + if (dp->alproto == alproto) { + return true; + } + dp = dp->next; + } + return false; +} /** * \brief Call the probing expectation to see if there is some for this flow. diff --git a/src/app-layer-detect-proto.h b/src/app-layer-detect-proto.h index 276eeea736..4e9147ca40 100644 --- a/src/app-layer-detect-proto.h +++ b/src/app-layer-detect-proto.h @@ -198,6 +198,8 @@ void AppLayerRegisterExpectationProto(uint8_t proto, AppProto alproto); void AppProtoDetectListNames(void); +bool AppLayerProtoDetectHasProbingParsers(uint8_t ipproto, uint16_t port, AppProto alproto); + /***** Unittests *****/ #ifdef UNITTESTS diff --git a/src/app-layer-smtp.c b/src/app-layer-smtp.c index 00f9bc14ab..285c495f40 100644 --- a/src/app-layer-smtp.c +++ b/src/app-layer-smtp.c @@ -1684,7 +1684,7 @@ static int SMTPStateGetEventInfoById( static AppProto SMTPClientProbingParserCheckPort( const Flow *f, uint8_t direction, const uint8_t *input, uint32_t len, uint8_t *rdir) { - if (f->dp == 21) { + if (AppLayerProtoDetectHasProbingParsers(IPPROTO_TCP, f->dp, ALPROTO_FTP)) { return ALPROTO_FAILED; } return ALPROTO_SMTP;