]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
tcp: tcp_connect - initialize bindip variable correctly, issue #4499
authorJaroslav Kysela <perex@perex.cz>
Tue, 12 Sep 2017 11:29:32 +0000 (13:29 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 18 Sep 2017 13:14:30 +0000 (15:14 +0200)
src/tcp.c

index 04c1998b001acf705de750f9bdec739a14f34460..ed057812fadf673cbbe59d1a0521a80fcf986953 100644 (file)
--- a/src/tcp.c
+++ b/src/tcp.c
@@ -85,6 +85,7 @@ tcp_connect(const char *hostname, int port, const char *bindaddr,
 
   errbuf[0] = '\0';
 
+  memset(&bindip, 0, sizeof(bindip));
   bindip.ss_family = AF_UNSPEC;
   if (bindaddr && bindaddr[0] != '\0') {
     if (tcp_get_ip_from_str(bindaddr, &bindip) == NULL) {
@@ -135,9 +136,10 @@ again:
 
   if (bindip.ss_family != AF_UNSPEC) {
     if (bind(fd, (struct sockaddr *)&bindip, IP_IN_ADDRLEN(bindip)) < 0) {
-      snprintf(errbuf, errbufsize, "Cannot bind to IPv%s addr '%s'",
+      snprintf(errbuf, errbufsize, "Cannot bind to IPv%s addr '%s:%i': %s",
                                    bindip.ss_family == AF_INET6 ? "6" : "4",
-                                   bindaddr);
+                                   bindaddr, htons(IP_PORT(bindip)),
+                                   strerror(errno));
       goto error;
     }
   }