dma: don't use sockaddr_storage.ss_len
authorSimon Schubert <corecode@dragonflybsd.org>
Sat, 3 Oct 2009 19:35:29 +0000 (21:35 +0200)
committerSimon Schubert <corecode@dragonflybsd.org>
Sat, 3 Oct 2009 20:45:30 +0000 (22:45 +0200)
sockaddr_storage.ss_len is not mandated by POSIX, so we shouldn't use
it.  Instead, use addrinfo.ai_addrlen.

libexec/dma/dns.c
libexec/dma/net.c

index 8cfdd04..5a72dfe 100644 (file)
@@ -97,7 +97,7 @@ add_host(int pref, const char *host, int port, struct mx_hostentry **he, size_t
                p->ai.ai_addr = NULL;
                bcopy(res->ai_addr, &p->sa, p->ai.ai_addrlen);
 
-               getnameinfo((struct sockaddr *)&p->sa, p->sa.ss_len,
+               getnameinfo((struct sockaddr *)&p->sa, p->ai.ai_addrlen,
                            p->addr, sizeof(p->addr),
                            NULL, 0, NI_NUMERICHOST);
 
index 607b992..55d06cf 100644 (file)
@@ -291,7 +291,7 @@ open_connection(struct mx_hostentry *h)
                return (-1);
        }
 
-       if (connect(fd, (struct sockaddr *)&h->sa, h->sa.ss_len) < 0) {
+       if (connect(fd, (struct sockaddr *)&h->sa, h->ai.ai_addrlen) < 0) {
                syslog(LOG_INFO, "connect to %s [%s] failed: %m",
                       h->host, h->addr);
                close(fd);