PR #24430 opened by Thomas Devoogdt (ThomasDevoogdt) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24430 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24430.patch
ff_rtp_parse_set_crypto() was void and dropped the ff_srtp_set_crypto() return value. A rejected crypto suite therefore left srtp_enabled clear while RTSPStream.crypto_suite stayed set, and rtsp.c uses crypto_suite[0] as the sole guard for secure transport. The session could thus be negotiated as SRTP while the RTP actually went out unprotected. Return the error instead and let ff_rtsp_open_transport_ctx() abort SETUP rather than continue with a half-initialised SRTP context. Signed-off-by: Thomas Devoogdt <[email protected]> # Summary of changes Briefly describe what this PR does and why. <!-- If this PR requires new FATE test samples, attach them to the PR and list their target paths below (relative to the fate-suite root). Attached filenames must match the sample's filename: ```fate-samples # e.g. vorbis/new-sample.ogg ``` --> >From e5d53ec8ab48550b3b3b34021d409a632666c3ec Mon Sep 17 00:00:00 2001 From: Thomas Devoogdt <[email protected]> Date: Thu, 16 Jul 2026 19:26:50 +0200 Subject: [PATCH] avformat/rtpdec: propagate SRTP setup errors to the caller ff_rtp_parse_set_crypto() was void and dropped the ff_srtp_set_crypto() return value. A rejected crypto suite therefore left srtp_enabled clear while RTSPStream.crypto_suite stayed set, and rtsp.c uses crypto_suite[0] as the sole guard for secure transport. The session could thus be negotiated as SRTP while the RTP actually went out unprotected. Return the error instead and let ff_rtsp_open_transport_ctx() abort SETUP rather than continue with a half-initialised SRTP context. Signed-off-by: Thomas Devoogdt <[email protected]> --- libavformat/rtpdec.c | 11 +++++++---- libavformat/rtpdec.h | 4 ++-- libavformat/rtsp.c | 14 ++++++++++---- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index 3fd817f93c..8842e636ad 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -584,11 +584,14 @@ void ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, s->handler = handler; } -void ff_rtp_parse_set_crypto(RTPDemuxContext *s, const char *suite, - const char *params) +int ff_rtp_parse_set_crypto(RTPDemuxContext *s, const char *suite, + const char *params) { - if (!ff_srtp_set_crypto(&s->srtp, suite, params)) - s->srtp_enabled = 1; + int ret = ff_srtp_set_crypto(&s->srtp, suite, params); + if (ret < 0) + return ret; + s->srtp_enabled = 1; + return 0; } static int rtp_set_prft(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestamp) { diff --git a/libavformat/rtpdec.h b/libavformat/rtpdec.h index c06f44b86c..0c2a293c9b 100644 --- a/libavformat/rtpdec.h +++ b/libavformat/rtpdec.h @@ -45,8 +45,8 @@ RTPDemuxContext *ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, int payload_type, int queue_size); void ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, const RTPDynamicProtocolHandler *handler); -void ff_rtp_parse_set_crypto(RTPDemuxContext *s, const char *suite, - const char *params); +int ff_rtp_parse_set_crypto(RTPDemuxContext *s, const char *suite, + const char *params); int ff_rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, uint8_t **buf, int len); void ff_rtp_parse_close(RTPDemuxContext *s); diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index b6f58f3102..6ca06bcdf7 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -916,10 +916,16 @@ int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st) rtsp_st->dynamic_protocol_context, rtsp_st->dynamic_handler); } - if (rtsp_st->crypto_suite[0]) - ff_rtp_parse_set_crypto(rtsp_st->transport_priv, - rtsp_st->crypto_suite, - rtsp_st->crypto_params); + if (rtsp_st->crypto_suite[0]) { + if (ff_rtp_parse_set_crypto(rtsp_st->transport_priv, + rtsp_st->crypto_suite, + rtsp_st->crypto_params) < 0) { + av_log(s, AV_LOG_ERROR, + "SRTP setup failed for suite '%s'\n", + rtsp_st->crypto_suite); + return AVERROR(EINVAL); + } + } } return 0; -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
