The branch, v3-2-test has been updated
       via  494bf6293bedbda4b10aa2eae452377b8130cd01 (commit)
       via  638579d75a2aa00836dc4c0c772381b775944b16 (commit)
      from  6b7ccd3efb05291f3b8779845a3842a09bb9aa07 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 494bf6293bedbda4b10aa2eae452377b8130cd01
Author: Jeremy Allison <[EMAIL PROTECTED]>
Date:   Fri Nov 2 14:23:10 2007 -0700

    Fix the snprintf checks, and fix a typo in pointer indirection.
    These fixes are needed for a working getaddrinfo etc. replacement.
    Fixes from Wayne Davison <[EMAIL PROTECTED]> from rsync.
    Jeremy.

commit 638579d75a2aa00836dc4c0c772381b775944b16
Author: Jeremy Allison <[EMAIL PROTECTED]>
Date:   Fri Nov 2 14:22:19 2007 -0700

    Ensure we use the correct socklen_t values for bind() for
    Solaris.
    Jeremy.

-----------------------------------------------------------------------

Summary of changes:
 source/lib/replace/getaddrinfo.c |   10 +++++-----
 source/lib/util_sock.c           |    4 +++-
 2 files changed, 8 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/replace/getaddrinfo.c b/source/lib/replace/getaddrinfo.c
index 063bacd..c5cd52b 100644
--- a/source/lib/replace/getaddrinfo.c
+++ b/source/lib/replace/getaddrinfo.c
@@ -222,7 +222,7 @@ static int getaddr_info_name(const char *node,
        }
 
        for(pptr = hp->h_addr_list; *pptr; pptr++) {
-               struct in_addr ip = *(struct in_addr *)pptr;
+               struct in_addr ip = *(struct in_addr *)*pptr;
                struct addrinfo *ai = alloc_entry(hints, ip, port);
 
                if (!ai) {
@@ -407,7 +407,7 @@ static int gethostnameinfo(const struct sockaddr *sa,
                if (ret == 0) {
                        /* Name looked up successfully. */
                        ret = snprintf(node, nodelen, "%s", hp->h_name);
-                       if (ret == -1 || ret > nodelen) {
+                       if (ret < 0 || (size_t)ret >= nodelen) {
                                return EAI_MEMORY;
                        }
                        if (flags & NI_NOFQDN) {
@@ -428,7 +428,7 @@ static int gethostnameinfo(const struct sockaddr *sa,
        }
        p = inet_ntoa(((struct sockaddr_in *)sa)->sin_addr);
        ret = snprintf(node, nodelen, "%s", p);
-       if (ret == -1 || ret > nodelen) {
+       if (ret < 0 || (size_t)ret >= nodelen) {
                return EAI_MEMORY;
        }
        return 0;
@@ -449,7 +449,7 @@ static int getservicenameinfo(const struct sockaddr *sa,
                if (se && se->s_name) {
                        /* Service name looked up successfully. */
                        ret = snprintf(service, servicelen, "%s", se->s_name);
-                       if (ret == -1 || ret > servicelen) {
+                       if (ret < 0 || (size_t)ret >= servicelen) {
                                return EAI_MEMORY;
                        }
                        return 0;
@@ -457,7 +457,7 @@ static int getservicenameinfo(const struct sockaddr *sa,
                /* Otherwise just fall into the numeric service code... */
        }
        ret = snprintf(service, servicelen, "%d", port);
-       if (ret == -1 || ret > servicelen) {
+       if (ret < 0 || (size_t)ret >= servicelen) {
                return EAI_MEMORY;
        }
        return 0;
diff --git a/source/lib/util_sock.c b/source/lib/util_sock.c
index b4fda54..4a73f92 100644
--- a/source/lib/util_sock.c
+++ b/source/lib/util_sock.c
@@ -1325,12 +1325,14 @@ int open_socket_in(int type,
 {
        struct sockaddr_storage sock;
        int res;
+       socklen_t slen = sizeof(struct sockaddr_in);
 
        sock = *psock;
 
 #if defined(HAVE_IPV6)
        if (sock.ss_family == AF_INET6) {
                ((struct sockaddr_in6 *)&sock)->sin6_port = htons(port);
+               slen = sizeof(struct sockaddr_in6);
        }
 #endif
        if (sock.ss_family == AF_INET) {
@@ -1374,7 +1376,7 @@ int open_socket_in(int type,
        }
 
        /* now we've got a socket - we need to bind it */
-       if( bind( res, (struct sockaddr *)&sock, sizeof(sock) ) == -1 ) {
+       if (bind(res, (struct sockaddr *)&sock, slen) == -1 ) {
                if( DEBUGLVL(dlevel) && (port == SMB_PORT1 ||
                                port == SMB_PORT2 || port == NMB_PORT) ) {
                        char addr[INET6_ADDRSTRLEN];


-- 
Samba Shared Repository

Reply via email to