[vlc-commits] httpd: fix parsing hostname variable

Rémi Denis-Courmont git at videolan.org
Wed Jun 27 19:12:57 CEST 2018


vlc/vlc-3.0 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jun 27 19:33:10 2018 +0300| [5b826919d0fe64b0fd86fae1273ac5b617cdd849] | committer: Rémi Denis-Courmont

httpd: fix parsing hostname variable

The variable is a hostname / address, not an URL.

(cherry picked from commit 8e1fcb90815408e5eab7dc269c8acdfc578ebaa9)
Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=5b826919d0fe64b0fd86fae1273ac5b617cdd849
---

 src/network/httpd.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/src/network/httpd.c b/src/network/httpd.c
index 1ff4f14d60..e517206232 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -910,18 +910,8 @@ static httpd_host_t *httpd_HostCreate(vlc_object_t *p_this,
                                        vlc_tls_creds_t *p_tls)
 {
     httpd_host_t *host;
-    char *hostname = var_InheritString(p_this, hostvar);
     unsigned port = var_InheritInteger(p_this, portvar);
 
-    vlc_url_t url;
-    vlc_UrlParse(&url, hostname);
-    free(hostname);
-    if (url.i_port != 0) {
-        msg_Err(p_this, "Ignoring port %d (using %d)", url.i_port, port);
-        msg_Info(p_this, "Specify port %d separately with the "
-                          "%s option instead.", url.i_port, portvar);
-    }
-
     /* to be sure to avoid multiple creation */
     vlc_mutex_lock(&httpd.mutex);
 
@@ -943,7 +933,6 @@ static httpd_host_t *httpd_HostCreate(vlc_object_t *p_this,
         vlc_mutex_unlock(&host->lock);
 
         vlc_mutex_unlock(&httpd.mutex);
-        vlc_UrlClean(&url);
         vlc_tls_Delete(p_tls);
         return host;
     }
@@ -958,7 +947,11 @@ static httpd_host_t *httpd_HostCreate(vlc_object_t *p_this,
     vlc_cond_init(&host->wait);
     host->i_ref = 1;
 
-    host->fds = net_ListenTCP(p_this, url.psz_host, port);
+    char *hostname = var_InheritString(p_this, hostvar);
+
+    host->fds = net_ListenTCP(p_this, hostname, port);
+    free(hostname);
+
     if (!host->fds) {
         msg_Err(p_this, "cannot create socket(s) for HTTP host");
         goto error;
@@ -983,8 +976,6 @@ static httpd_host_t *httpd_HostCreate(vlc_object_t *p_this,
     TAB_APPEND(httpd.i_host, httpd.host, host);
     vlc_mutex_unlock(&httpd.mutex);
 
-    vlc_UrlClean(&url);
-
     return host;
 
 error:
@@ -997,7 +988,6 @@ error:
         vlc_object_release(host);
     }
 
-    vlc_UrlClean(&url);
     vlc_tls_Delete(p_tls);
     return NULL;
 }



More information about the vlc-commits mailing list