Ensure that the RTP payload type is within the valid
range defined by the RTP specification (0-127).

Invalid payload types could otherwise lead to
incorrect RTP packet construction.

Signed-off-by: Devraj Ajmera <[email protected]>
---
 libavformat/rtpenc.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 1d4b00a0f4..153ba25257 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -113,6 +113,13 @@ static int rtp_write_header(AVFormatContext *s1)
         return -1;
     }
 
+    if (s->payload_type > 127) {
+        av_log(s1, AV_LOG_ERROR,
+               "Invalid RTP payload type %d (must be 0-127)\n",
+               s->payload_type);
+        return AVERROR(EINVAL);
+    }
+
     if (s->payload_type < 0) {
         /* Re-validate non-dynamic payload types */
         if (st->id < RTP_PT_PRIVATE)
-- 
2.53.0.windows.1

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to