]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
httpc: fix http_port() - NULL scheme
authorJaroslav Kysela <perex@perex.cz>
Tue, 20 May 2014 14:00:48 +0000 (16:00 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 20 May 2014 14:05:54 +0000 (16:05 +0200)
src/httpc.c

index ddd5beda348b1bbcad1ef74f5af2ab84ad411918..a2bbdcdd904d60acef8294b870f8008e707666c7 100644 (file)
@@ -84,14 +84,14 @@ static int
 http_port( const char *scheme, int port )
 {
   if (port <= 0 || port > 65535) {
-    if (strcmp(scheme, "http") == 0)
+    if (scheme && strcmp(scheme, "http") == 0)
       port = 80;
-    else if (strcmp(scheme, "https") == 0)
+    else if (scheme && strcmp(scheme, "https") == 0)
       port = 443;
-    else if (strcmp(scheme, "rtsp") == 0)
+    else if (scheme && strcmp(scheme, "rtsp") == 0)
       port = 554;
     else {
-      tvhlog(LOG_ERR, "httpc", "Unknown scheme '%s'", scheme);
+      tvhlog(LOG_ERR, "httpc", "Unknown scheme '%s'", scheme ? scheme : "");
       return -EINVAL;
     }
   }
@@ -1162,6 +1162,8 @@ http_client_reconnect
   hc->hc_scheme  = strdup(scheme);
   hc->hc_host    = strdup(host);
   hc->hc_port    = port;
+  if (port < 0)
+    return -EINVAL;
   hc->hc_fd      = tcp_connect(host, port, errbuf, sizeof(errbuf), -1);
   if (hc->hc_fd < 0) {
     tvhlog(LOG_ERR, "httpc", "Unable to connect to %s:%i - %s", host, port, errbuf);