Author: metze
Date: 2007-11-09 08:22:21 +0000 (Fri, 09 Nov 2007)
New Revision: 25909

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25909

Log:
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.

from v3-2-test commit 494bf6293bedbda4b10aa2eae452377b8130cd01
Modified:
   branches/SAMBA_4_0/source/lib/replace/getaddrinfo.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/replace/getaddrinfo.c
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/getaddrinfo.c 2007-11-09 07:52:32 UTC 
(rev 25908)
+++ branches/SAMBA_4_0/source/lib/replace/getaddrinfo.c 2007-11-09 08:22:21 UTC 
(rev 25909)
@@ -222,7 +222,7 @@
        }
 
        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 @@
                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 @@
        }
        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 @@
                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 @@
                /* 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;

Reply via email to