This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit df3511db5bdfe315ac8fe553c0a70e5e1b156c69 Author: Aditya Banavi <[email protected]> AuthorDate: Sat Mar 28 06:50:10 2026 +0000 Commit: Jack Lau <[email protected]> CommitDate: Wed May 27 11:39:32 2026 +0000 avformat/tls: Moved the parsing of host uri into a separate function - ff_tls_parse_host() This makes the function reusable and modular Signed-off-by: Aditya Banavi <[email protected]> --- libavformat/tls.c | 33 ++++++++++++++++++++++----------- libavformat/tls.h | 2 ++ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/libavformat/tls.c b/libavformat/tls.c index 031ca74c94..3eab305f56 100644 --- a/libavformat/tls.c +++ b/libavformat/tls.c @@ -32,12 +32,30 @@ #include "libavutil/mem.h" #include "libavutil/parseutils.h" +int ff_tls_parse_host(TLSShared *s, char *hostname, int hostname_size, int *port_ptr, const char *uri) +{ + struct addrinfo hints = { .ai_flags = AI_NUMERICHOST }, *ai; + + if (!hostname || hostname_size <= 0) + return AVERROR(EINVAL); + + av_url_split(NULL, 0, NULL, 0, hostname, hostname_size, port_ptr, NULL, 0, uri); + if (!getaddrinfo(hostname, NULL, &hints, &ai)) { + s->numerichost = 1; + freeaddrinfo(ai); + } + + if (!s->host && !(s->host = av_strdup(hostname))) + return AVERROR(ENOMEM); + + return 0; +} + int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AVDictionary **options) { int port; const char *p; char buf[200], opts[50] = ""; - struct addrinfo hints = { 0 }, *ai = NULL; const char *proxy_path; char *env_http_proxy, *env_no_proxy; int use_proxy; @@ -53,7 +71,9 @@ int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AV if (c->listen && !c->is_dtls) snprintf(opts, sizeof(opts), "?listen=1"); - av_url_split(NULL, 0, NULL, 0, c->underlying_host, sizeof(c->underlying_host), &port, NULL, 0, uri); + ret = ff_tls_parse_host(c, c->underlying_host, sizeof(c->underlying_host), &port, uri); + if (ret < 0) + return ret; if (!p) { p = opts; @@ -64,15 +84,6 @@ int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AV ff_url_join(buf, sizeof(buf), c->is_dtls ? "udp" : "tcp", NULL, (c->is_dtls && c->listen) ? "" : c->underlying_host, port, "%s", p); - hints.ai_flags = AI_NUMERICHOST; - if (!getaddrinfo(c->underlying_host, NULL, &hints, &ai)) { - c->numerichost = 1; - freeaddrinfo(ai); - } - - if (!c->host && !(c->host = av_strdup(c->underlying_host))) - return AVERROR(ENOMEM); - env_http_proxy = getenv_utf8("http_proxy"); proxy_path = c->http_proxy ? c->http_proxy : env_http_proxy; diff --git a/libavformat/tls.h b/libavformat/tls.h index 8f459fdd9d..971ae5c7a5 100644 --- a/libavformat/tls.h +++ b/libavformat/tls.h @@ -115,6 +115,8 @@ typedef struct TLSShared { {"key_pem", "Private key PEM string", offsetof(pstruct, options_field . key_buf), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \ FF_TLS_CLIENT_OPTIONS(pstruct, options_field) +int ff_tls_parse_host(TLSShared *s, char *hostname, int hostname_size, int *port_ptr, const char *uri); + int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AVDictionary **options); int ff_url_read_all(const char *url, AVBPrint *bp); _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
