From 03511d7bb464f95780e08181ea149b5a0ac61e55 Mon Sep 17 00:00:00 2001 From: "fredrik@DOLDA2000.COM" Date: Fri, 29 Apr 2005 02:26:18 +0000 Subject: [PATCH] Small cleanups. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/icmp-dn@218 959494ce-11ee-0310-bf91-de5d638817bd --- nss-icmp.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/nss-icmp.c b/nss-icmp.c index 1e3d8cd..305573f 100644 --- a/nss-icmp.c +++ b/nss-icmp.c @@ -20,7 +20,7 @@ enum nss_status _nss_icmp_gethostbyaddr_r(const void *addr, socklen_t len, int a char retaddr[16]; } *retbuf; char addrbuf[1024]; - int an; + int an, thislen; char *p, *p2, *p3; u_int8_t *ap; pid_t child; @@ -97,14 +97,17 @@ enum nss_status _nss_icmp_gethostbyaddr_r(const void *addr, socklen_t len, int a p3 = buffer + sizeof(*retbuf); while((p2 = strchr(p, '\n')) != NULL) { *p2 = 0; - if((p3 - buffer) + (p2 - p) + 1 > buflen) { + thislen = p2 - p; + if(thislen == 0) + continue; + if((p3 - buffer) + thislen + 1 > buflen) { *errnop = ENOMEM; *h_errnop = NETDB_INTERNAL; return(NSS_STATUS_UNAVAIL); } - memcpy(p3, p, (p2 - p) + 1); + memcpy(p3, p, thislen + 1); retbuf->aliaslist[an] = p3; - p3 += (p2 - p) + 1; + p3 += thislen + 1; p = p2 + 1; if(++an == 16) { *errnop = ENOMEM; @@ -113,7 +116,7 @@ enum nss_status _nss_icmp_gethostbyaddr_r(const void *addr, socklen_t len, int a } } if(an == 0) { - *h_errnop = TRY_AGAIN; /* Is this correct? */ + *h_errnop = TRY_AGAIN; /* XXX: Is this correct? */ return(NSS_STATUS_NOTFOUND); } retbuf->aliaslist[an] = NULL; -- 2.11.0