[FFmpeg-devel] [PATCH 2/3] udp: Check the port number provided by av_url_split as per docs

Derek Buitenhuis derek.buitenhuis at gmail.com
Wed Nov 22 17:28:41 EET 2017


Signed-off-by: Derek Buitenhuis <derekb at vimeo.com>
---
 libavformat/udp.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 0dde035..7bbd282 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -443,6 +443,10 @@ int ff_udp_set_remote_url(URLContext *h, const char *uri)
     const char *p;
 
     av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
+    if (port < 0) {
+        av_log(s, AV_LOG_ERROR, "No valid port number found in URL.\n");
+        return AVERROR(EINVAL);
+    }
 
     /* set the destination address */
     s->dest_addr_len = udp_set_url(h, &s->dest_addr, hostname, port);
@@ -798,6 +802,10 @@ static int udp_open(URLContext *h, const char *uri, int flags)
 
     /* fill the dest addr */
     av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
+    if (port < 0) {
+        av_log(h, AV_LOG_ERROR, "Missing or invalid port provided in URL.\n");
+        return AVERROR(EINVAL);
+    }
 
     /* XXX: fix av_url_split */
     if (hostname[0] == '\0' || hostname[0] == '?') {
-- 
1.8.3.1



More information about the ffmpeg-devel mailing list