diff options
author | Stefan Metzmacher <metze@samba.org> | 2007-11-09 08:22:21 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2007-12-21 05:44:50 +0100 |
commit | a4a7447f130d144317e9b7d110ea20f046cd708f (patch) | |
tree | b00b18354d463d5201534043f9c5f4b0d64122ef /source4/lib/replace/getaddrinfo.c | |
parent | 82ae4d5543343debf5fbca320aa22ad931178c18 (diff) | |
download | samba-a4a7447f130d144317e9b7d110ea20f046cd708f.tar.gz samba-a4a7447f130d144317e9b7d110ea20f046cd708f.tar.bz2 samba-a4a7447f130d144317e9b7d110ea20f046cd708f.zip |
r25909: 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 <wayned@samba.org> from rsync.
Jeremy.
from v3-2-test commit 494bf6293bedbda4b10aa2eae452377b8130cd01
(This used to be commit e562832ad19e8c3a0380759a22b0267e365ecc2e)
Diffstat (limited to 'source4/lib/replace/getaddrinfo.c')
-rw-r--r-- | source4/lib/replace/getaddrinfo.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/source4/lib/replace/getaddrinfo.c b/source4/lib/replace/getaddrinfo.c index 063bacd026..c5cd52be93 100644 --- a/source4/lib/replace/getaddrinfo.c +++ b/source4/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; |